componentWillReceiveProps not firing even though state has clearly changed in the reducer











up vote
0
down vote

favorite












i know there's a lot of answers to this same question on SO, however i've read through them and none seem to solve the problem i am seeing. really need someone's help on this.



scenario: we have an existing React Native app (v0.42.3) that is in the App Store and all was well. Today due to an errant 3rd party library, we needed to delete node_modules and rebuild. That has been done and no issues. The app launches fine. However now for some reason, the login flow is broken and it "seems" to be due to Redux. Its just a simple login flow. Here are hopefully all the details:



user taps login -> call action creator -> success -> call reducer -> update state which invokes mapStateToProps(state)



the problem i can't solve yet - is that :
1) mapStateToProps IS firing and you can see that the needed property (displayLoginModal) has changed from true to false



2) componentWillReceiveProps is NOT firing which breaks the app flow



Action Creator



 ..auth worked fine, then call..

dispatch({
type: LOGIN_USER_SUCCESS,
payload: { user: userInfo },
greeting: isNewUser ? "welcome" : "hi",
isLoggedIn: true,
waitingForLoginCompletion: false
});

dispatch({ type: SHOW_LOGIN_MODAL, display: false });


Reducer



case SHOW_LOGIN_MODAL:
return {
...state,
displayLoginModal: action.display
};

case LOGIN_USER_SUCCESS:
return {
...state,
user: action.payload,
greeting: action.greeting,
error: "",
loginUserError: "",
faceBookLoading: false,
googleLoading: false
};


The "Receiving/Listening Component (LoginView)



am using the @connect decorator



Here is the mapStateToProps function:



function mapStateToProps(state) {
console.log(state) <== **IMPORTANT. this IS showing that the prop has changed
const {
email,
password,
error,
... etc...
displayLoginModal <== this is the prop that IS changing (from true, to false)
} = state.auth;

return {
..snip.. other props etc...
displayLoginModal, <== returning it here
isConnectedToFirebase
};
}

....
@connect(
mapStateToProps,
{
updateTermsOfUseAndPrivacy,
emailChanged,
passwordChanged,
errorMessageChanged,
loginUserWithEmail,
loginUserWithFacebook,
facebookLogin,
googleLogin,
loginUserWithGoogle,
resetUserPassword,
setTermsOfUseAndPrivacy,
logout,
resetPasswordComplete
}
)
export default class LoginView extends Component {
... etc


So again - even thought mapStateToProps IS firing and displays the change in the properties value correctly - for some weird unknown reason to me componentWillReceiveProps is NOT firing.



Why ? This is a serious blocker for us at moment so greatly appreciate some help and advice. Hopefully its something obvious I've missed.










share|improve this question


























    up vote
    0
    down vote

    favorite












    i know there's a lot of answers to this same question on SO, however i've read through them and none seem to solve the problem i am seeing. really need someone's help on this.



    scenario: we have an existing React Native app (v0.42.3) that is in the App Store and all was well. Today due to an errant 3rd party library, we needed to delete node_modules and rebuild. That has been done and no issues. The app launches fine. However now for some reason, the login flow is broken and it "seems" to be due to Redux. Its just a simple login flow. Here are hopefully all the details:



    user taps login -> call action creator -> success -> call reducer -> update state which invokes mapStateToProps(state)



    the problem i can't solve yet - is that :
    1) mapStateToProps IS firing and you can see that the needed property (displayLoginModal) has changed from true to false



    2) componentWillReceiveProps is NOT firing which breaks the app flow



    Action Creator



     ..auth worked fine, then call..

    dispatch({
    type: LOGIN_USER_SUCCESS,
    payload: { user: userInfo },
    greeting: isNewUser ? "welcome" : "hi",
    isLoggedIn: true,
    waitingForLoginCompletion: false
    });

    dispatch({ type: SHOW_LOGIN_MODAL, display: false });


    Reducer



    case SHOW_LOGIN_MODAL:
    return {
    ...state,
    displayLoginModal: action.display
    };

    case LOGIN_USER_SUCCESS:
    return {
    ...state,
    user: action.payload,
    greeting: action.greeting,
    error: "",
    loginUserError: "",
    faceBookLoading: false,
    googleLoading: false
    };


    The "Receiving/Listening Component (LoginView)



    am using the @connect decorator



    Here is the mapStateToProps function:



    function mapStateToProps(state) {
    console.log(state) <== **IMPORTANT. this IS showing that the prop has changed
    const {
    email,
    password,
    error,
    ... etc...
    displayLoginModal <== this is the prop that IS changing (from true, to false)
    } = state.auth;

    return {
    ..snip.. other props etc...
    displayLoginModal, <== returning it here
    isConnectedToFirebase
    };
    }

    ....
    @connect(
    mapStateToProps,
    {
    updateTermsOfUseAndPrivacy,
    emailChanged,
    passwordChanged,
    errorMessageChanged,
    loginUserWithEmail,
    loginUserWithFacebook,
    facebookLogin,
    googleLogin,
    loginUserWithGoogle,
    resetUserPassword,
    setTermsOfUseAndPrivacy,
    logout,
    resetPasswordComplete
    }
    )
    export default class LoginView extends Component {
    ... etc


    So again - even thought mapStateToProps IS firing and displays the change in the properties value correctly - for some weird unknown reason to me componentWillReceiveProps is NOT firing.



    Why ? This is a serious blocker for us at moment so greatly appreciate some help and advice. Hopefully its something obvious I've missed.










    share|improve this question
























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      i know there's a lot of answers to this same question on SO, however i've read through them and none seem to solve the problem i am seeing. really need someone's help on this.



      scenario: we have an existing React Native app (v0.42.3) that is in the App Store and all was well. Today due to an errant 3rd party library, we needed to delete node_modules and rebuild. That has been done and no issues. The app launches fine. However now for some reason, the login flow is broken and it "seems" to be due to Redux. Its just a simple login flow. Here are hopefully all the details:



      user taps login -> call action creator -> success -> call reducer -> update state which invokes mapStateToProps(state)



      the problem i can't solve yet - is that :
      1) mapStateToProps IS firing and you can see that the needed property (displayLoginModal) has changed from true to false



      2) componentWillReceiveProps is NOT firing which breaks the app flow



      Action Creator



       ..auth worked fine, then call..

      dispatch({
      type: LOGIN_USER_SUCCESS,
      payload: { user: userInfo },
      greeting: isNewUser ? "welcome" : "hi",
      isLoggedIn: true,
      waitingForLoginCompletion: false
      });

      dispatch({ type: SHOW_LOGIN_MODAL, display: false });


      Reducer



      case SHOW_LOGIN_MODAL:
      return {
      ...state,
      displayLoginModal: action.display
      };

      case LOGIN_USER_SUCCESS:
      return {
      ...state,
      user: action.payload,
      greeting: action.greeting,
      error: "",
      loginUserError: "",
      faceBookLoading: false,
      googleLoading: false
      };


      The "Receiving/Listening Component (LoginView)



      am using the @connect decorator



      Here is the mapStateToProps function:



      function mapStateToProps(state) {
      console.log(state) <== **IMPORTANT. this IS showing that the prop has changed
      const {
      email,
      password,
      error,
      ... etc...
      displayLoginModal <== this is the prop that IS changing (from true, to false)
      } = state.auth;

      return {
      ..snip.. other props etc...
      displayLoginModal, <== returning it here
      isConnectedToFirebase
      };
      }

      ....
      @connect(
      mapStateToProps,
      {
      updateTermsOfUseAndPrivacy,
      emailChanged,
      passwordChanged,
      errorMessageChanged,
      loginUserWithEmail,
      loginUserWithFacebook,
      facebookLogin,
      googleLogin,
      loginUserWithGoogle,
      resetUserPassword,
      setTermsOfUseAndPrivacy,
      logout,
      resetPasswordComplete
      }
      )
      export default class LoginView extends Component {
      ... etc


      So again - even thought mapStateToProps IS firing and displays the change in the properties value correctly - for some weird unknown reason to me componentWillReceiveProps is NOT firing.



      Why ? This is a serious blocker for us at moment so greatly appreciate some help and advice. Hopefully its something obvious I've missed.










      share|improve this question













      i know there's a lot of answers to this same question on SO, however i've read through them and none seem to solve the problem i am seeing. really need someone's help on this.



      scenario: we have an existing React Native app (v0.42.3) that is in the App Store and all was well. Today due to an errant 3rd party library, we needed to delete node_modules and rebuild. That has been done and no issues. The app launches fine. However now for some reason, the login flow is broken and it "seems" to be due to Redux. Its just a simple login flow. Here are hopefully all the details:



      user taps login -> call action creator -> success -> call reducer -> update state which invokes mapStateToProps(state)



      the problem i can't solve yet - is that :
      1) mapStateToProps IS firing and you can see that the needed property (displayLoginModal) has changed from true to false



      2) componentWillReceiveProps is NOT firing which breaks the app flow



      Action Creator



       ..auth worked fine, then call..

      dispatch({
      type: LOGIN_USER_SUCCESS,
      payload: { user: userInfo },
      greeting: isNewUser ? "welcome" : "hi",
      isLoggedIn: true,
      waitingForLoginCompletion: false
      });

      dispatch({ type: SHOW_LOGIN_MODAL, display: false });


      Reducer



      case SHOW_LOGIN_MODAL:
      return {
      ...state,
      displayLoginModal: action.display
      };

      case LOGIN_USER_SUCCESS:
      return {
      ...state,
      user: action.payload,
      greeting: action.greeting,
      error: "",
      loginUserError: "",
      faceBookLoading: false,
      googleLoading: false
      };


      The "Receiving/Listening Component (LoginView)



      am using the @connect decorator



      Here is the mapStateToProps function:



      function mapStateToProps(state) {
      console.log(state) <== **IMPORTANT. this IS showing that the prop has changed
      const {
      email,
      password,
      error,
      ... etc...
      displayLoginModal <== this is the prop that IS changing (from true, to false)
      } = state.auth;

      return {
      ..snip.. other props etc...
      displayLoginModal, <== returning it here
      isConnectedToFirebase
      };
      }

      ....
      @connect(
      mapStateToProps,
      {
      updateTermsOfUseAndPrivacy,
      emailChanged,
      passwordChanged,
      errorMessageChanged,
      loginUserWithEmail,
      loginUserWithFacebook,
      facebookLogin,
      googleLogin,
      loginUserWithGoogle,
      resetUserPassword,
      setTermsOfUseAndPrivacy,
      logout,
      resetPasswordComplete
      }
      )
      export default class LoginView extends Component {
      ... etc


      So again - even thought mapStateToProps IS firing and displays the change in the properties value correctly - for some weird unknown reason to me componentWillReceiveProps is NOT firing.



      Why ? This is a serious blocker for us at moment so greatly appreciate some help and advice. Hopefully its something obvious I've missed.







      react-native redux react-native-ios






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 18 at 2:06









      ajonno

      547621




      547621
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          alright - this is sorted. the issue here, had NOTHING to do with Redux. It was due a missing route. Not that any of the cryptic / non-existent error messages had anything to do with that. I take responsibility, but I will say I'm officially no longer a fan of React Native. death by a thousand cuts.






          share|improve this answer





















            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














             

            draft saved


            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53357287%2fcomponentwillreceiveprops-not-firing-even-though-state-has-clearly-changed-in-th%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            0
            down vote













            alright - this is sorted. the issue here, had NOTHING to do with Redux. It was due a missing route. Not that any of the cryptic / non-existent error messages had anything to do with that. I take responsibility, but I will say I'm officially no longer a fan of React Native. death by a thousand cuts.






            share|improve this answer

























              up vote
              0
              down vote













              alright - this is sorted. the issue here, had NOTHING to do with Redux. It was due a missing route. Not that any of the cryptic / non-existent error messages had anything to do with that. I take responsibility, but I will say I'm officially no longer a fan of React Native. death by a thousand cuts.






              share|improve this answer























                up vote
                0
                down vote










                up vote
                0
                down vote









                alright - this is sorted. the issue here, had NOTHING to do with Redux. It was due a missing route. Not that any of the cryptic / non-existent error messages had anything to do with that. I take responsibility, but I will say I'm officially no longer a fan of React Native. death by a thousand cuts.






                share|improve this answer












                alright - this is sorted. the issue here, had NOTHING to do with Redux. It was due a missing route. Not that any of the cryptic / non-existent error messages had anything to do with that. I take responsibility, but I will say I'm officially no longer a fan of React Native. death by a thousand cuts.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 18 at 3:12









                ajonno

                547621




                547621






























                     

                    draft saved


                    draft discarded



















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53357287%2fcomponentwillreceiveprops-not-firing-even-though-state-has-clearly-changed-in-th%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Create new schema in PostgreSQL using DBeaver

                    Deepest pit of an array with Javascript: test on Codility

                    Costa Masnaga