Skip to content
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

react/no-multi-comp false positive when wrapping inline stateless with React.memo #2145

Closed
aaronmccall opened this issue Jan 24, 2019 · 0 comments
Assignees

Comments

@aaronmccall
Copy link

Given the following code

import React from 'react';

const TestStateless = React.memo(props => (
  <div>{props.children}</div>
));

class Test extends React.Component {
  render() {
    return <TestStateless><p>I am wrapped in TestStateless</p></TestStateless>
  }
}
export default Test;

and rule config,

"react/no-multi-comp": ["error", { "ignoreStateless": true }]

I would expect no error, but I get errors as though ignoreStateless were its default of false.

When I define the stateless component outside React.memo then wrap it,

import React from 'react';

const stateless = props => <div>{props.children}</div>
const TestStateless = React.memo(stateless);

class Test extends React.Component {
  render() {
    return <TestStateless><p>I am wrapped in TestStateless</p></TestStateless>
  }
}
export default Test;

there are no errors.

@yannickcr yannickcr self-assigned this Jan 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants