As migrating from react-navigation v1 to react-navigation v3 and not storing the navigation state inside reducer I'am getting this error

    react-navigation : ^3.0.9
    react-native: "https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz"

Before migration I'am using navigation reducer to store state below code is from NavigationRedux

    const appNavigationReducer = (state, action) => {
     let newState
      console.log('state',state)
      console.log('Action',action)

      if (action.type === 'LOGIN_STATE') {
        newState = AppNavigation.router.getStateForAction(loginState, state)
      }
      else {
        newState = AppNavigation.router.getStateForAction(action, state)
      }

      return newState || state
    }

   //RootContainer finishLoading function which is used by AppLoading

    _finishLoading = () => {
        const currentUser = store.getState().user.currentUser

        if (!!currentUser) {
          this.props.login()
        }

        this.setState({ ready: true })
      }


    //This is a render method of root container

     render () {
        return (
          <View style={ styles.applicationView }>
            { !this.state.ready &&
                <AppLoading
                  startAsync={ this._loadStuff }
                  onFinish={ this._finishLoading }
                  onError={ console.warn }
                />
            }
            { this.state.ready &&
              <View style={ styles.applicationView }>
                <ReduxNavigation loggedIn={ this.props.loggedIn }  />
                <Notification />
                <CheckInConfirmation />
              </View>
            }
          </View>
        )
      }

// mapDispatchToProps of Root container class

    const mapDispatchToProps = (dispatch) => ({
      login: () => dispatch({ type: 'LOGIN_STATE' })
    })

0 Answers