Fullstack Web Developer . Interested in Machine Learnig.
help ing you in your coding journey.
Thank you for your effort but I didn't get what problem this article trying to address. If you want to run certain function only when user clicks then put that function inside the click event handler. You want to achieve that useEffect should not run after first render but even after your workaround it still runs, just your if condition is passing hence else block is not executing in first render.