In my useEffect hook i have a few API requests, like:
useEffect(() => {
dispatch(action1());
dispatch(action2());
dispatch(action3());
}, []);
How can i use 'loading' parameter inside hook using async/await function to have loading as true before dispatching first request, and as false after dispatching last request. Like:
const [loading, setLoading] = useState(false);
useEffect(() => {
setLoading(true);
dispatch(action1());
dispatch(action2());
dispatch(action3());
setLoading(false);
}, []);