0

I'm having problem with useEffect it fired twice when the page rendered my code below

  useEffect(() => {
    if (!jwt) {
      console.log('you are not login');
    } else {
      console.log(cookie.GREEN_COOKIE);
    }

    fetchEvents();
  }, []);

enter image description here

erwin
  • 99
  • 2
  • 9
  • Does this answer your question? [Why useEffect running twice and how to handle it well in React?](https://stackoverflow.com/questions/72238175/why-useeffect-running-twice-and-how-to-handle-it-well-in-react) – Youssouf Oumar Feb 11 '23 at 16:37

1 Answers1

0

Something is causing your component to re-render.

Without seeing any other code or props of the component it's difficult to say what.

craigw
  • 627
  • 3
  • 8