I have this code
useEffect(() => {
console.log('SHOWING LAYOUT');
return () => {
if (!auth.isChangePasswordSuccess) {
console.log('SHOWING LAYOUT 2', auth.isChangePasswordSuccess);
dispatch(updateAuth('status', userStatus.LOGGED_IN));
}
}
}, [auth.isChangePasswordSuccess]);
On the first load of the screen, 'SHOWING LAYOUT' appears on my console with the auth.isChangePasswordSuccess having a value of false. But when I change the value auth.isChangePasswordSuccess to true, useEffect() is triggered displaying the 'SHOWING LAYOUT 2' in the console, but the value of auth.isChangePasswordSuccess is still false.
Any idea why the value of the redux state is not affected in the chain function call? I confirmed with the other my other useEffect() that the value is already changed to true.