Reputation: 2164
Looking for a best practice for updating UI after data changed.
For example: I'm trying add post and when he has been added i need it shown on same page. Without reloading page.
Is that correct way if i'll call action
in body of another action
?
For example: On Success post added -> call action which fetch all posts
componentWillReceiveProps(nextProps) {
if (nextProps.success) { call action }
}
Thanks!
Upvotes: 2
Views: 855
Reputation: 2449
Best practice AFAIK for what I understand you are asking would be to use something like React-thunk, so you can have async actions.
A thunk is a function that wraps an expression to delay its evaluation.
with that you can avoid componentWillReceiveProps, pass down all your state through props to the dumb components from a controller component connected to the store.
Upvotes: 1