1、React Native 多次点击按钮引发多次进入界面的问题:
解决:将react navigation 集成redux 后:
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); // you might want to replace 'null' with 'state' if you're using redux (see comments below) }; MainStackRouter.router.getStateForAction = navigateOnce(MainStackRouter.router.getStateForAction); const initialState = MainStackRouter.router.getStateForAction(MainStackRouter.router.getActionForPathAndParams('Splash')); const navReducer = (state = initialState, action) => { const nextState = MainStackRouter.router.getStateForAction(action, state); // Simply return the original `state` if `nextState` is null or undefined. return nextState || state; };2、