react native can't find variable center

2522 views react-native
0

When ever I try to position my text center I get the error that variable 'center' can not be found. Am I doing something wrong or is did I not do it correctly?

import React, {Component} from 'react';
import {Platform, StyleSheet, Text, View, Image} from 'react-native';


type Props = {};
export default class App extends Component<Props> {
render() {
  return (
    <View>
        <Text style={styles.titel}>Random Text</Text>
    </View>
  );
 }
}

const styles = StyleSheet.create({
  titel:{
     color: 'black',
     justifyContent: center,
     alignItems: center,
  }
});

answered question

1 Answer

3

center is not a variable, it is a string therefore you need to add it as

  titel:{
     color: 'black',
     justifyContent: 'center',
     alignItems: 'center',
  }

posted this

Have an answer?

JD

Please login first before posting an answer.