I have a variable isVisible that holds a boolean value. When this variable changes, I need to make a reload of the component, but only one time. And if the variable changes again at some point, then run this reload again for one time, but not continuously. Currently, I have this code that runs continuously:
useEffect(() => {
if (isVisible) {
window.location.reload();
}
}, [ isVisible ]);
How is this possible to achieve? Can someone tell me why this component is reloading continuously, even when I add the variable in dependency array?