Rules
no-nested-components
Full Name in eslint-plugin-react-x
Full Name in @eslint-react/eslint-plugin
Features
🔍
Presets
core
recommended
recommended-typescript
recommended-type-checked
What it does
Prevents nesting component definitions inside other components.
Nesting component definitions inside other components is a common mistake that can be extremely slow and cause issues and bugs, and the state of components defined during rendering will not be preserved by React. Instead, define every component at the top level.
Examples
Failing
Passing
When a child component needs some data from a parent, pass it by props instead of nesting definitions.