Skip to content

react/prop-types false positive when component is exported to a different name #2051

Closed
@bdwain

Description

@bdwain

I have a component that is giving me false positives saying that a proptype is not defined.

'children' is missing in props validation react/prop-types

Here's an example

import React from 'react';
import PropTypes from 'prop-types';
import makeHoc from './make-hoc';
import selectors from './selectors';

class Foo extends React.Component {
  render() {
    return this.props.children;
  }
}

Foo.propTypes = {
  children: PropTypes.element.isRequired
};

export const Unconnected = Foo; //this line causes the issue
export default makeHoc(
  Foo,
  selectors
);

and it works if I change commented line above to this

export { Foo as Unconnected };

At first I thought #1958 was related but on second look it doesn't seem to be. I also tried downgrading to 7.10.0 and that didn't help.

I don't see anything wrong with that syntax, but please point out if I'm missing something. Thanks!

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions