Answer the question
In order to leave comments, you need to log in
Delays in react-redux, is this normal?
Good, a question arose - in a react application, by clicking on a block, a function is called
const handleClick = (e) => {
dispatch(clickActions.add([e.clientX, e.clientY]));
}
const points = useSelector(state => state.points)
// ... импорты
const Comp = () => {
const dispatch = useDispatch();
const points = useSelector(state => state.points);
const handleClick = (e) => {
dispatch(actions.clickActions.add([e.clientX, e.clientY]);
// вот тут я уже хочу использовать данные из стора
console.log(points); // Выводится старые данные, до диспатча, вопрос как все это дело переделать
}
return <button onClick={handleClick}>Click</button>;
}
// ... экспорт
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question