Answer the question
In order to leave comments, you need to log in
How does the React-Redux reducer work?
Good afternoon! I started learning Redux and then a question arose - my application is written using React / Redux . There is a button on clicking on which certain actions are performed
const changeAmount = (top) => {
dispatch({ type: DATA_FOR_REPOSTS_CHANGE_TOP, data: top });
dispatch(getListReportsApiAction(isDataForReports));
};
useEffect(() => {
dispatch(getListReportsApiAction(isDataForReports));
console.log(isReports);
}, [isDataForReports]);
Answer the question
In order to leave comments, you need to log in
When calling the second dispatcher, the state does not yet have the data that you sent with the first dispatcher
Solution - use thunk or, as you did, useEffect
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question