childrenProps
Reports usage of the children prop.
✅ This rule is included in the jsx stylistic presets.
In JSX, children are generally intended to be passed as content between opening and closing tags rather than as a children prop.
This makes the JSX more readable and maintainable by following the standard JSX pattern.
Examples
Section titled “Examples”<JSX.IntrinsicElements.div: DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>
div DOMAttributes<HTMLDivElement>.children?: ReactNode
children="Hello" /><const Component: any
Component children: JSX.Element
children={<JSX.IntrinsicElements.span: DetailedHTMLProps<HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>
span>Test</JSX.IntrinsicElements.span: DetailedHTMLProps<HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>
span>} />;<JSX.IntrinsicElements.button: DetailedHTMLProps<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>
button DOMAttributes<HTMLButtonElement>.children?: ReactNode
children={["Click me"]} /><JSX.IntrinsicElements.div: DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>
div>Hello</JSX.IntrinsicElements.div: DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>
div><const Component: any
Component> <JSX.IntrinsicElements.span: DetailedHTMLProps<HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>
span>Test</JSX.IntrinsicElements.span: DetailedHTMLProps<HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>
span></const Component: any
Component>;<JSX.IntrinsicElements.button: DetailedHTMLProps<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>
button>Click me</JSX.IntrinsicElements.button: DetailedHTMLProps<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>
button>When Not To Use It
Section titled “When Not To Use It”If you prefer the consistency of always using named props including children over aligning with common JSX conventions, you might prefer to disable this rule.
Further Reading
Section titled “Further Reading”Equivalents in Other Linters
Section titled “Equivalents in Other Linters”- Deno:
jsx-no-children-prop - ESLint:
react/no-children-prop
Made with ❤️🔥 around the world by
the Flint team and contributors.