New
Introducing React Doctor for Enterprise

react-doctor/no-react-children

Pass children as props or render them directly instead of calling React.Children methods.

Validation prompt

Use this to decide whether a fired diagnostic is real or a false positive.

Fires on a call whose callee is a member access on the React Children namespace — either Children.<method>(...) where Children was imported from 'react', or React.Children.<method>(...) where React is the local name of any react import (covering map, forEach, only, count, toArray, and the parenthesized or as any forms). It does NOT fire on a locally-declared Children object, a Children imported from a non-react module, or the bare strings/JSX text "Children". False positive: React.Children.only / React.Children.map used as a deliberate runtime invariant (e.g. enforcing a single child in a tooltip or trigger wrapper) — that is a valid, intentional pattern, not a bug, which is exactly why this rule ships off by default.

Fix prompt

Use this once validation confirms the diagnostic is real.

Prefer plumbing children through directly: accept the children prop and render {children}, or pass renderable nodes as explicit props (e.g. <Layout header={<Header />} body={<Body />} />) instead of slicing a children collection apart. When you need per-child wrapping, map over an explicit array prop rather than Children.map(children, ...): items.map(item => <Row key={item.id}>{item.node}</Row>). If a single-child invariant is genuinely required, keep React.Children.only and add an eslint-disable with a justification. See https://oxc.rs/docs/guide/usage/linter/rules/react/no-react-children

More Architecture rules from the rules reference:

  • react-doctor/no-react-dom-deprecated-apis: Switch the legacy `react-dom` root API (`render` / `hydrate` / `unmountComponentAtNode`) to `createRoot` / `hydrateRoot` / `root.unmount()` from `react-dom/client`. Replace `findDOMNode` with a ref. The whole `react-dom/test-utils` entry point is removed in React 19 — use `act` from `react` and `fireEvent` / `render` from `@testing-library/react`. Only enabled on projects detected as React 18+.
  • react-doctor/no-react19-deprecated-apis: Pass `ref` as a regular prop on function components — `forwardRef` is no longer needed in React 19+. Replace `useContext(X)` with `use(X)` for branch-aware context reads. Only enabled on projects detected as React 19+.
  • react-doctor/no-redundant-should-component-update: Drop shouldComponentUpdate when extending PureComponent, or extend React.Component if custom comparison logic is genuinely needed.
  • react-doctor/no-render-in-render: Extract to a named component: `const ListItem = ({ item }) => <div>{item.name}</div>`
  • react-doctor/no-render-prop-children: Replace `renderXxx` props with compound subcomponents (e.g. `<Modal.Header>`) or `children` so the parent doesn't dictate every customization point