Rules
no-children-map
Full Name in eslint-plugin-react-x
react-x/no-children-mapFull Name in @eslint-react/eslint-plugin
@eslint-react/no-children-mapPresets
xrecommendedrecommended-typescriptrecommended-type-checked
Description
Disallow the use of Children.map from the react package.
Using Children is uncommon and can lead to fragile code. See common alternatives.
Examples
Failing
import React, { Children } from "react";
interface MyComponentProps {
children: React.ReactNode;
}
function MyComponent({ children }: MyComponentProps) {
return (
<div className="RowList">
{Children.map(children, (child) => <div className="Row">{child}</div>)}
</div>
);
}Implementation
Further Reading
See Also
no-children-count
Prevents the use ofChildren.countfrom thereactpackage.no-children-for-each
Prevents the use ofChildren.forEachfrom thereactpackage.no-children-only
Prevents the use ofChildren.onlyfrom thereactpackage.no-children-to-array
Prevents the use ofChildren.toArrayfrom thereactpackage.