Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

react native can't find variable center

Tags:

react-native

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,
  }
});
like image 725
Oner20 Avatar asked Mar 28 '26 00:03

Oner20


1 Answers

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

  titel:{
     color: 'black',
     justifyContent: 'center',
     alignItems: 'center',
  }
like image 82
Pritish Vaidya Avatar answered Mar 31 '26 09:03

Pritish Vaidya



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!