Eslint-plugin-react: Stateless components with flow props broken in v6.1.0

Created on 15 Aug 2016  路  1Comment  路  Source: yannickcr/eslint-plugin-react

This commit appears to be what introduced the problem: https://github.com/yannickcr/eslint-plugin-react/commit/763382f8d4ec5961c765bbb71cd2698016da5b53. Perhaps an alternative approach to solving that problem could be using how the types are referenced in the code - as the first argument to a stateless component, or passed in as a type parameter to React.Component for stateful ones, rather than based on a naming convention

In v6.0.0, this code was fine:

type MyComponentProps = {
  a: number,
  b: string,
};

function MyComponent({ a, b }: MyComponentProps) {
  return <div />;
}

In v6.1.0, that gives 'a' is missing in props validation and 'b' is missing in props validation. If I change the code to

type Props = {
  a: number,
  b: string,
};

function MyComponent({ a, b }: Props) {
  return <div />;
}

everything works fine.

Thanks for your great work on this project! :)

bug flow

Most helpful comment

Working on it.

>All comments

Working on it.

Was this page helpful?
0 / 5 - 0 ratings