0

I am practicing react js in my laptop i am practicing life cycle methods and hooks if I write console log in my code to see which one is executing first and which one is executing second. Then it is showing two times in the console as a result.

i didnt tried because i am beginner

  • 1
    React executes useEffect hook twice in development mode, its done on purpose to catch bugs https://beta.reactjs.org/learn/synchronizing-with-effects#how-to-handle-the-effect-firing-twice-in-development possibly already answered: https://stackoverflow.com/questions/74333903/the-function-of-my-code-runs-twice-instead-of-once/74333995#74333995 – Azzy Nov 10 '22 at 10:45

1 Answers1

0

This is happening because you are probably using React Strict mode, check your index file, then you can confirm, for your testing purposes you can remove this and give it a try.

shamal iroshan
  • 189
  • 1
  • 3
  • 7