no-unstable-nested-components
Configuration
Rule Details
Creating components inside components causes React to see a new component type on every render. Because React identifies a component by its reference, a new reference forces React to unmount the existing subtree and mount a fresh one on every parent render — losing DOM state, triggering layout effects, and leaking memory. Move nested component definitions to the module scope (or accept data through props).
Examples of incorrect code for this rule:
Examples of correct code for this rule:
Options
allowAsProps
Allow components to be declared inside other components' props without reporting. Defaults to false.
propNamePattern
Glob pattern matched against JSX attribute / object-literal property names. When the pattern matches, a component defined in that position is treated as a render prop and is NOT reported. Defaults to "render*".