Rules
react/no-children-for-each

react/no-children-for-each

Rule category

Restriction.

What it does

Prevents usage of Children.forEach.

Why is this bad?

Using Children is uncommon and can lead to fragile code. See common alternatives (opens in a new tab).

Examples

❌ Incorrect

import { Children } from "react";
 
function SeparatorList({ children }) {
  const result = [];
  Children.forEach(children, (child, index) => {
    result.push(child);
    result.push(<hr key={index} />);
  });
  // ...
}

Further reading