79639553

Date: 2025-05-26 21:01:17
Score: 1
Natty:
Report link

This is expected behavior in React 18 when using Strict Mode in development.

React intentionally runs effects twice (setup → cleanup → setup) to help catch bugs with side effects and cleanup logic. In production, the effect runs only once.

You can read the official explanation here: My Effect runs twice when the component mounts.

If this causes issues, make sure your effect has a proper cleanup function.

Reasons:
  • No code block (0.5):
  • Low reputation (0.5):
Posted by: PasVV