title |
---|
no-children-only |
Full Name in eslint-plugin-react-x
react-x/no-children-only
Full Name in @eslint-react/eslint-plugin
@eslint-react/no-children-only
Presets
x
recommended
recommended-typescript
recommended-type-checked
Disallow the use of Children.only
from the react
package.
Using Children
is uncommon and can lead to fragile code. See common alternatives.
import React, { Children } from "react";
interface MyComponentProps {
children: React.ReactNode;
}
function MyComponent({ children }: MyComponentProps) {
const element = Children.only(children);
// ...
}
no-children-count
Prevents the use ofChildren.count
from thereact
package.no-children-for-each
Prevents the use ofChildren.forEach
from thereact
package.no-children-map
Prevents the use ofChildren.map
from thereact
package.no-children-to-array
Prevents the use ofChildren.toArray
from thereact
package.