我在RN项目中使用“反应导航”和react-native-router-flux 在android上一切正常 但是在IOS上有警告
您应该只在应用中显式呈现一个导航器,而另一个 导航器应通过将其包含在该导航器中来呈现。 有关详细信息,请访问: https://reactnavigation.org/docs/common-mistakes.html#explicitly-rendering-more-than-one-navigator -警告中的node_modules / expo / build / environment / logging.js:25:23 -node_modules/@react-navigation/native/src/createAppContainer.js:198:12 在componentDidMount $中 -node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:62:44 在tryCatch中 -node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:288:30 在调用 -node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:62:44 在tryCatch中 -node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:152:28 在调用 -node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:187:17 在
这是我的App.js
...
return (
<Provider store={store}>
<RouterWithRedux>
<Router>
<Stack key="root" hideNavBar={true}>
<Scene
key="loginScreen"
hideNavBar
component={requireAuthNOT(LoginScreen)}
title="Please Sign in"
/>
<Scene
key="ticketsListScreen"
component={requireAuth(TicketsListScreen)}
animation="fade"
title="Home"
hideNavBar={true}
/>
<Scene
key="ticketDetail"
component={requireAuth(LoginDetail)}
animation="fade"
hideNavBar={true}
/>
</Stack>
</Router>
</RouterWithRedux>
</Provider>
);
...
LoginScreen.js
import React, { Component } from "react";
import Logo from "../components/Auth/Logo";
import Form from "../components/Auth/Form";
import Wallpaper from "../components/Auth/Wallpaper";
import ButtonSubmit from "../components/Auth/ButtonSubmit";
import SignupSection from "../components/Auth/SignupSection";
export default class LoginScreen extends Component {
render() {
return (
<Wallpaper>
<Logo />
<Form />
<SignupSection />
<ButtonSubmit />
</Wallpaper>
);
}
}
TicketsListScreen.js
import React, { Component } from "react";
import Navigator from "./Navigator";
export default class ScreenTest extends Component {
render() {
return <Navigator />;
}
}
Navigator.js
import React, { Component } from "react";
import TicketsListScreen from "./TicketsListScreen";
import VehicleScreen from "../VehicleScreen/VehicleScreen";
import SideBar from "../../components/Navigator/SideBar";
import SignOut from "../../screens/LogoutScreen";
import { createDrawerNavigator, createAppContainer } from "react-navigation";
const TicketScreenRouter = createDrawerNavigator(
{
Home: { screen: TicketsListScreen },
Tickets: { screen: TicketsListScreen },
"Vehicle Inspections": { screen: VehicleScreen },
"Sign Out": { screen: SignOut }
},
{
contentComponent: props => <SideBar {...props} />
},
{
initialRouteName: "Home"
}
);
export default createAppContainer(TicketScreenRouter);
我不确定是什么问题。 我已阅读https://reactnavigation.org/docs/common-mistakes.html#explicitly-rendering-more-than-one-navigator
但这对我没有帮助
致以最诚挚的问候
答案 0 :(得分:0)
这是app.js
return (
<Provider store={store}>
<RouterWithRedux>
<Scene key="root" hideNavBar={true}>
<Scene
key="loginScreen"
hideNavBar
component={requireAuthNOT(LoginScreen)}
title="Please Sign in"
/>
<Drawer
open={false}
type="overlay"
key="drawer"
contentComponent={SideBar}>
<Scene
key="VehicleInsections"
component={requireAuth(VehicleScreen)}
animation="fade"
title="Vehicle"
hideNavBar={true}
/>
</Scene>
</RouterWithRedux>
</Provider>
);
}
目前,这对我也很有效 再次感谢https://stackoverflow.com/users/9799857/firu。