What you described is very similar to react strict mode behavior. If you're in development mode, it is active by default
This is the relevant part from the documentation:
Strict Mode enables the following development-only behaviors:
Your components will re-render an extra time to find bugs caused by impure rendering. Your components will re-run Effects an extra time to find bugs caused by missing Effect cleanup. Your components will re-run refs callbacks an extra time to find bugs caused by missing ref cleanup. Your components will be checked for usage of deprecated APIs.