Documentation
Rules
no-children-map

no-children-map

Rule category

Restriction.

What it does

Prevents the use of Children.map from the react package.

Why is this bad?

Using Children is uncommon and can lead to fragile code. See common alternatives.

Examples

Failing

import React, { Children } from "react";
 
interface ExampleProps {
  children: React.ReactNode;
}
 
function Example({ children }: ExampleProps) {
  return (
    <div className="RowList">
      {Children.map(children, (child) => (
        <div className="Row">{child}</div>
      ))}
    </div>
  );
}

Further reading