Skip to content

Proposal: alter no-children-prop to allow functions #1803

@erfanio

Description

@erfanio

If you use react router, is some situations you need to pass a function as children.
It would be nice to be able to use the same syntax as them.

<Route path={to} children={({ match }) => (
  <li className={match ? 'active' : ''}>
    <Link to={to} {...rest}/>
  </li>
)} />

is easier to reason about than

<Route path={to}>
  {({ match }) => (
    <li className={match ? 'active' : ''}>
      <Link to={to} {...rest}/>
    </li>
  )}
</Route>

There could be a config to allow functions (not the default).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions