在react-native导航中,同一屏幕在stack-navigation中呈现2-3次

时间:2018-06-21 06:42:20

标签: react-native react-navigation

同一屏幕渲染两次,如屏幕截图所示。如何解决这个问题?

同一屏幕多次显示

same screen multiple time
“反应导航”:“ ^ 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
)

0 个答案:

没有答案