Add note about StrictMode not as the root component (#7702)

This commit is contained in:
Ricky
2025-03-31 12:58:06 -04:00
committed by GitHub
parent 9f87530c0e
commit 38ee8d2a4f

View File

@@ -122,6 +122,12 @@ function App() {
In this example, Strict Mode checks will not run against the `Header` and `Footer` components. However, they will run on `Sidebar` and `Content`, as well as all of the components inside them, no matter how deep.
<Note>
When `StrictMode` is enabled for a part of the app, React will only enable behaviors that are possible in production. For example, if `<StrictMode>` is not enabled at the root of the app, it will not [re-run Effects an extra time](#fixing-bugs-found-by-cleaning-up-and-re-attaching-dom-refs-in-development) on initial mount, since this would cause child effects to double fire without the parent effects, which cannot happen in production.
</Note>
---
### Fixing bugs found by double rendering in development {/*fixing-bugs-found-by-double-rendering-in-development*/}