Reputation: 75
I am trying to apply some styles in my react native application but it's not working with me, I tried to run it in the browser this is the output showed up:
But when I run it in my phone it's showing me an error:
This is the main App.js file:
import { StatusBar } from 'expo-status-bar';
import React from 'react';
import { View } from 'react-native';
import HomeMenu from './src/screens/Home/index';
export default function App() {
return (
<View style={{ flex: 1 }}>
<StatusBar style="auto" />
<HomeMenu />
</View>
);
}
And this is index.js file (the one I want to show its results):
import React from 'react';
import { View, Text, StyleSheet, SafeAreaView } from 'react-native';
const HomeMenu = () => {
return (
<SafeAreaView style={{ flex: 1 }}> //add flex:1 here
<View style={styles.container}>
<Text>Open up App.js to start working on your app!</Text>
</View>
</SafeAreaView>
);
};
export default HomeMenu;
const styles = StyleSheet.create({
container: {
flex: 3,
backgroundColor: '#21534A',
alignItems: 'center',
justifyContent: 'center',
},
});
Upvotes: 1
Views: 2055
Reputation: 605
try like this:-
import React from 'react';
import { View, Text, StyleSheet, SafeAreaView } from 'react-native';
const HomeMenu = () => {
return (
<SafeAreaView style={{ flex: 1 }}>
//add flex:1 here
<View style={styles.container}>
<Text>Open up App.js to start working on your app!</Text>
</View>
</SafeAreaView>
);
};
export default HomeMenu;
const styles = StyleSheet.create({
container: {
flex: 3,
backgroundColor: '#21534A',
alignItems: 'center',
justifyContent: 'center',
},
});
Upvotes: 1