Skip to content

Latest commit

 

History

History
67 lines (46 loc) · 1.61 KB

File metadata and controls

67 lines (46 loc) · 1.61 KB
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

Description

Disallow the use of Children.only 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) {
  const element = Children.only(children);
  // ...
}

Implementation

Further Reading


See Also