Answer the question
In order to leave comments, you need to log in
How to do redux dispatch inside useEffect?
const function Component = () => {
const data = useSelector(state => state.data);
useEffect(async () => {
const {token} = queryString.parse(location.search):
const response = await fetch(...).then(res => res.json());
if (!response.status) {
dispatch(updateError(true));
}
}, []);
};
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