React native redux map state to props not working

后端 未结 2 525
轮回少年
轮回少年 2020-12-18 05:45

I am new to react-native and I am trying to implement a simple sign up functionality using react-redux. For some reasons , mapping the state to props in connect is not work

相关标签:
2条回答
  • 2020-12-18 06:38

    From your store defination,

    return combineReducers({
            nav: navReducer,
            signUpReducer : signUpReducer,
        });
    

    You defined the key signUpReducer for your SignUp component state. In order to access the state of this component,you should use this key followed by the state name.

    The correct way to access user is :

     export default connect(
          state => ({
              user : state.signUpReducer.user 
          })
    

    //use signUpReducer key

    0 讨论(0)
  • 2020-12-18 06:44

    FOR ME ALSO THIS IS WORKING componentWillReceiveProps(nextProps)

    componentWillReceiveProps(nextProps) {
    
     console.log();
     this.setState({propUser : nextProps.user})
    }
    
    0 讨论(0)
提交回复
热议问题