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.
react-native redux react-native-ios
add a comment |
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.
react-native redux react-native-ios
add a comment |
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.
react-native redux react-native-ios
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
react-native redux react-native-ios
asked Nov 18 at 2:06
ajonno
547621
547621
add a comment |
add a comment |
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.
add a comment |
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.
add a comment |
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.
add a comment |
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.
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.
answered Nov 18 at 3:12
ajonno
547621
547621
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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