Here is my code. The demo site is here.
On the demo web page, I have 2 buttons, 1 is the "go" button, the other one is the "Back" button, when I click on the "go" button, the console will show the state and action twice. So, I try to use the useEffect hook to fix the problem.
useEffect(()=>{ flag=true; },[dispatch]) Although it can solve the "go" button problem, when I click on the "Back" button, the reducer cannot print the state and action to the console. How can I fix the problem?
没有评论:
发表评论