[英]Why is content not showing in react-navigation component?
Why is content not showing in react-navigation component?为什么内容没有显示在 react-navigation 组件中?
I am using react-navigation and I am trying to display the content of我正在使用 react-navigation 并且我正在尝试显示的内容, but the content is not displayed
, 但内容不显示
Im used styled-components/native
我使用了样式化组件/本机
My code:我的代码:
const Stack = createStackNavigator();
const Screens = () => {
return (
<NavigationContainer>
<Stack.Navigator>
<Stack.Screen name="Home" component={Home} />
</Stack.Navigator>
</NavigationContainer>
);
};
Home:家:
export const Home = () => {
return (
<HomeContainer>
<Text>Hello world!</Text>
</HomeContainer>
);
};
This also does not work, the result is the same as in the screenshot:
const Home = () => {
return (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: 'red' }}>
<Text>Hello world!</Text>
</View>
);
};
export default Home;
I created a working snack demo you can check that here.我创建了一个工作小吃演示,您可以在此处查看。
https://snack.expo.io/@raajnadar/react-navigation-setup-with-styled-component https://snack.expo.io/@raajnadar/react-navigation-setup-with-styled-component
You are using multiple navigation containers that is wrong.您正在使用错误的多个导航容器。 If you want to use multiple navigation containers you need to configure them properly and make sure you have a proper use case for that.
如果你想使用多个导航容器,你需要正确配置它们并确保你有一个合适的用例。
https://reactnavigation.org/docs/navigation-container/ https://reactnavigation.org/docs/navigation-container/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.