Reputation: 1226
I have a react native project and I am using redux actions and reducers to handle my store.
I have a smart connected component and I call my actions through dispatch in componentWillMount()
and then I have mapStateToProps
and I map the data I get from my store to props.
Problem is the only way to check if the props are changed, is by putting it inside render
function. In my case I want to navigate to another page if I get props filled with some data. It all works fine but I get warning from React that its anti pattern. Is there any other way of doing this? Am I doing it right?
Upvotes: 1
Views: 487
Reputation: 2701
You should implement the method componentWillReceiveProps instead of comparing the values in the render
Another (preferable) approach would be the action responsible to update the values, do the navigation (or dispatch another actions that would do the navigation stuff). Check redux-thunk
Upvotes: 2