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 Hook + Memo support #5

Open
brandon-pereira opened this issue Jan 30, 2019 · 4 comments
Open

React Hook + Memo support #5

brandon-pereira opened this issue Jan 30, 2019 · 4 comments

Comments

@brandon-pereira
Copy link

Hey! Love the addon!

I'm getting a proptype warning when using with React hooks.

My component:

const Navigation = React.memo((props) => {
  return (<div />);
});

Navigation.defaultProps = {
  routes: []
};
Navigation.propTypes = {
  routes: PropTypes.array
};

logs warning:

checkPropTypes.js:19 Warning: Failed prop type: Invalid prop `type` of type `object` supplied to `PropTable`, expected `function`.
    in PropTable
    in Unknown
    in div
    in div
    in div
    in div
    in div
    in Story

When I remove the React.memo() wrapper around my component, the warning goes away.

I'm open to helping resolve the issue if needed. It seems to be like a prop warning (proptable is rendering fine) so maybe we can just make the prop type more generic?

@brandon-pereira
Copy link
Author

brandon-pereira commented Jan 30, 2019

Actually, an update on this.. it seems the displayName is being stripped UNLESS I also add PropTypes.displayName = 'navigation'. But, thats not a problem.. I've updated my generator to automatically add this.

@hipstersmoothie
Copy link
Owner

@brandon-pereira any chance i could get a full reproduction repo to play around with?

@zach-aries
Copy link

I'm also having this issue when wrapping components in React.memo().
Note that for me, my 'propTypes' column disappears.

Screen Shot 2019-03-27 at 3 43 00 PM

@hipstersmoothie hipstersmoothie changed the title React Hook support React Hook + Memo support Mar 28, 2019
@hipstersmoothie
Copy link
Owner

@zach-aries example repo would be 🔥

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

No branches or pull requests

3 participants