同一屏幕渲染两次,如屏幕截图所示。如何解决这个问题?
“反应导航”:“ ^ 1.0.0-beta.11”,
import Login from "../components/login/";
import Signup from "../components/signup/";
HomeDrawerRouter.navigationOptions = ({ navigation }) => ({
header: null
});
const screens = {
Login: { screen: Login, path: 'Login/:messageScreen', navigationOptions: {
gesturesEnabled: false, header: null
} },
Signup: { screen: Signup, navigationOptions: {
gesturesEnabled: false, header: null
} }}
let MainStackRouter = StackNavigator(screens,
{
initialRouteName: index
})
const navigateOnce = getStateForAction => (action, state) => {
const { type, routeName } = action
return state &&
type === NavigationActions.NAVIGATE &&
routeName === state.routes[state.routes.length - 1].routeName
? null
: getStateForAction(action, state)
}
MainStackRouter.router.getStateForAction = navigateOnce(
MainStackRouter.router.getStateForAction
)