Bug: useEffect() clears timeout immediately after a focus event with StrictMode #33008
Labels
Status: Unconfirmed
A potential issue that we haven't yet confirmed as a bug
8000
React version: 18.3.1
Steps To Reproduce
Link to code example: https://stackblitz.com/edit/vitejs-vite-nnvwzvcm
The current behavior
2025-04-24.13.50.07.mp4
The expected behavior
Without
StrictMode
a dispose function is not called:2025-04-24.13.51.24.mp4
That's a simplified version of the issue from microsoft/fluentui#34296. I clearly understand that it's not a bug in React. It does what's expected 👍
The correct approach is to fire
setTimeout()
&clearTimeout()
inuseEffect()
. The problem is that the described pattern is not unique and adopted by component libraries:So we are wondering what is a proper solution in case and looking for guidance in this particular case 🙏
The text was updated successfully, but these errors were encountered: