how to wait for something and then trigger in react using hooks code example
Example: usestate wait for set
const [loading, setLoading] = useState(false);
...
useEffect(() => {
doSomething(); // This is be executed when `loading` state changes
}, [loading])
setLoading(true);