Skip to content

react/display-name doesn't trigger when functional compo includes named function #2221

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dwelle opened this issue Mar 29, 2019 · 3 comments
Closed

Comments

@dwelle
Copy link
Contributor

dwelle commented Mar 29, 2019

When a functional component includes a named function in its body, the react/display-name rule does not trigger for the wrapping component.

export default function () {

    function fetchData () {} // <-- causes react/display-name not to trigger

    return <div/>;
}
  • eslint: 5.15.3
  • eslint-plugin-react: 7.12.4
@ljharb
Copy link
Member

ljharb commented Apr 3, 2019

Although I'd suggest never creating a function inside an SFC (inside the render path), this definitely sounds like a bug.

@dwelle
Copy link
Contributor Author

dwelle commented Apr 3, 2019

When using hooks, you almost exclusively often create functions inside FCs.

@ljharb
Copy link
Member

ljharb commented Apr 3, 2019

That doesn't mean it's a good idea, it just means hooks might encourage that pattern.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants