When I use useEffect with hooks inside it does not update state:
const App = () => {
const [isLoading, setLoading] = useState(false);
useEffect(() => {
Alert.alert('Before setLoading: ' + isLoading);
setLoading(true);
Alert.alert('After setLoading: ' + isLoading);
}, []);
...
}
Both times it alerts:
Before setLoading: false
After setLoading: false
Can you please suggest why it behaves this way?