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

PropType Validation fails #3

Closed
larrydahooster opened this issue Apr 15, 2016 · 2 comments
Closed

PropType Validation fails #3

larrydahooster opened this issue Apr 15, 2016 · 2 comments
Labels

Comments

@larrydahooster
Copy link

larrydahooster commented Apr 15, 2016

Hey, I tested your library and it works pretty good so far. Anyhow I get the following error on initialization:

sizeme-example.js:691 Warning: Failed propType: Required prop size.width was not specified in SizeMeRender. Check the render method of SizeAwareComponent

I checked the code and you set

SizeMeRender.propTypes = {
  ...
    size: PropTypes.shape({
      width: PropTypes.number.isRequired,
      height: PropTypes.number.isRequired,
    })
  };

but width and height are undefined in the first runs (which is pretty much the intended functionality).

bildschirmfoto 2016-04-15 um 11 20 17

Wouldn't it be better to change it to:

SizeMeRender.propTypes = {
  ...
    size: PropTypes.shape({
      width: PropTypes.number,
      height: PropTypes.number,
    }).isRequired
  };

This way you enforce the shape, but allow the props inside of the shape to be undefined?

@ctrlplusb ctrlplusb added the bug label Apr 15, 2016
@ctrlplusb
Copy link
Owner

Well spotted sir thank you. Hmmm, I need to get my test environment to throw on warnings. I'll look into that. Expect a patch today.

Much appreciate the time you took to test this for me.

@ctrlplusb
Copy link
Owner

Sorted thank you! 💖

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

No branches or pull requests

2 participants