I've written this piece of code using Hooks in React:
useEffect(() => {
const runEffect = async () => {
const data = await AsyncFunction();
console.log('async operation')
};
runEffect();
});
useEffect(() => {
console.log('useEffect-1')
});
useEffect(() => {
console.log('useEffect-2')
});
The result is this:
useEffect-1
useEffect-2
async operation
But I want to wait for async useEffect and then call another use effects, i.e. I want the expected result to be:
async operation
useEffect-1
useEffect-2
How it could be done?
regards