facebook / prop-types

Runtime type checking for React props and similar objects
MIT License
4.48k stars 356 forks source link

memo instance not recognized as PropTypes.func #275

Closed ashercoren closed 5 years ago

ashercoren commented 5 years ago

Consider the following propTypes decoration:

MyComponent.propTypes = {
    element: PropTypes.func,
}

Providing a simple React function (element={(props) => ...}) works fine, but if I wrap the function with React.memo, I get the following warning:

Failed prop type: Invalid prop `element` of type `object` supplied to `MyComponent`, expected `function`.
ljharb commented 5 years ago

It’s not a function.

If you’re trying to make a propType for “thing you can make an element from”, you may want elementType?

ashercoren commented 5 years ago

thanks.