Skip to content

[Bug]: react/no-children-prop does not report function as children in the child position when allowFunctions is true #4005

@jasongerbes-vista

Description

@jasongerbes-vista

Is there an existing issue for this?

  • I have searched the existing issues and my issue is unique
  • My issue appears in the command-line and not only in the text editor

Description Overview

When allowFunctions is set to true, the react/no-children-prop rule does not report function as children in the child position, which contradicts the documented behaviour for this option.

According to the rule docs under allowFunctions:

When true, and passing a function as children, it must be in prop position and not child position.

The following patterns are considered warnings:

<MyComponent>{data => data.value}</MyComponent>
React.createElement(MyComponent, {}, data => data.value)

ES Lint config:

"react/no-children-prop": ["error", {
  "allowFunctions": true
}]

Example:

<MyComponent>{data => data.value}</MyComponent>

No error is reported for the above code.

This contradicts the documentation, which states that when allowFunctions is true, functions should not be passed as children in the child position.

Expected Behavior

When allowFunctions is true, functions as children in the child position should be reported as incorrect code.

eslint-plugin-react version

v7.37.5

eslint version

v9.39.1

node version

v24.12.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions