I'm having a problem updating useState() inside of useEffect(). I think I may be running into an infinite loop and useState isn't updating regardless of the booleans that I pass in. It always shows false.
export const useAlert = () => {
const action = useSelector(state => state.edit.action);
const dispatch = useDispatch();
const booleanA = true;
const booleanB = false;
const [isOverMax, setIsOverMax] = useState(false);
const reset = () => {
dispatch(resetEditAction());
};
useEffect(() => {
setIsOverMax(booleanA || booleanB);
}, isOverMax);
return [isOverMax, reset];
};
For more context, booleanA and booleanB are dynamically generated with other code, but even when they are hardcoded like above, isOverMax only ever is false. I can never get a true value, even when both booleans are hardcoded as true.