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 nullObjectPattern #26

Open
guipasmoi opened this issue Jul 3, 2017 · 1 comment
Open

Proptype nullObjectPattern #26

guipasmoi opened this issue Jul 3, 2017 · 1 comment

Comments

@guipasmoi
Copy link
Collaborator

No description provided.

@guipasmoi
Copy link
Collaborator Author

guipasmoi commented Jul 3, 2017

there is an issue with propTypes with our nullObjectPattern, we will get warnings

class Details extends Component {
  static propTypes = {
    athlete: PropTypes.shape({
      firstname: PropTypes.string,
      lastname: PropTypes.string,
      profil: PropTypes.string
    }).isRequired
  };
...
}

we have to create a PropTypes for it
ex:

 // You can also specify a custom validator. It should return an Error
  // object if the validation fails. Don't `console.warn` or throw, as this
  // won't work inside `oneOfType`.
  customProp: function(props, propName, componentName) {
    if (!/matchme/.test(props[propName])) {
      return new Error(
        'Invalid prop `' + propName + '` supplied to' +
        ' `' + componentName + '`. Validation failed.'
      );
    }
  },

https://facebook.github.io/react/docs/typechecking-with-proptypes.html

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

1 participant