1//In case of hooks, you should use useEffect hook.
2const [fruit, setFruit] = useState('');
3
4setFruit('Apple');
5
6useEffect(() => {
7 console.log('Fruit', fruit);
8}, [fruit])
9
1//if some of your code depends on that state update you can use a useeffect like this
2 useEffect(() => {
3 if (currentProgress[index].progress === 100) {
4 GoBack()
5 }
6 }, [currentProgress])
7