no-children-count
Full Name in eslint-plugin-react-x
react-x/no-children-countFull Name in @eslint-react/eslint-plugin
@eslint-react/no-children-countFeatures
🔍
Presets
corerecommendedrecommended-typescriptrecommended-type-checked
What it does
Prevents the use of Children.count 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 (
<>
<h1>Total rows: {Children.count(children)}</h1>
...
</>
);
}