when I dispatch
an action in Redux the store is updated sequentially, ie if I have the following thunk:
function action(data) {
return function(dispatch) {
dispatch(anotherAction(data));
dispatch(anotherActionAfterTheAboveUpdatesTheStore(data));
};
}
The store is updated sequentially, meaning that after dispatch(anotherAction(data));
the store is already changed.
However, I know that internally when we dispatch an action, react-redux
re-renders a connected component through its setState
method, which is asynchronous. Therefore I have some difficulties in understanding when does React effectively re-render the component with the new data.
Does it somehow guarantees to call render()
after each Redux's dispatch
?
Thank you for the attention.
It actually doesn't have much to do with redux. Redux just updates the state and react-redux passes parts of the state as props . Now it's up to React to detect that some props have changed and to run it's lifecycle methods and re-render if necessary.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.