const [loading, setLoading] = useState(false); ... useEffect(() => { doSomething(); // This is be executed when `loading` state changes }, [loading]) setLoading(true);