0

I am currently dealing with two screens: Login and EmployeeList and didn't set initialRouteName.

I have combined two reducers: NavReducer and AuthReducer. I am receiving state.auth in LoginForm and state.nav in RouterWithNavigationState like so:

class RouterWithNavigationState extends Component{
    ...
    <Router navigation = {addNavigationHelpers({
                    dispatch: this.props.dispatch,
                    state: this.props.navigation
                })} />
    ...
    }

    const mapStateToProps = state =>
    {
        console.log (state.nav)
        return 
        {
           navigation: state.nav
        } 
    }
    export default connect(mapStateToProps)(RouterWithNavigationState)


However I get an error:
(1) mapStateToProps() in Connect(RouterWithNavigationState) must return a plain object. Instead received undefined.
(2) addNavigationHelpers is not a function

The log statement prints the initial state I defined in NavReducer.js like so: {index: 0, routes: Array(1)}


package.json:
"dependencies": { "firebase": "^4.13.1", "react": "16.3.1", "react-native": "0.55.3", "react-navigation": "^2.0.1", "react-redux": "^5.0.7", "redux": "^4.0.0", "redux-thunk": "^2.2.0" }, "devDependencies": { "babel-jest": "22.4.3", "babel-preset-react-native": "4.0.0", "jest": "22.4.3", "react-test-renderer": "16.3.1" }

What am I missing?

SwethaG
  • 133
  • 1
  • 2
  • 12
  • Possible duplicate of [Javascript function fails to return object when there is a line-break between the return statement and the object?](https://stackoverflow.com/questions/18221963/javascript-function-fails-to-return-object-when-there-is-a-line-break-between-th) – Andrew Li May 15 '18 at 12:40
  • 1
    Also see: http://stackoverflow.com/questions/2846283/what-are-the-rules-for-javascripts-automatic-semicolon-insertion-asi – Andrew Li May 15 '18 at 12:40

0 Answers0