-
Notifications
You must be signed in to change notification settings - Fork 49
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
Usage with React propTypes #96
Comments
you get to the value by either |
But then every propType will end in React.PropType.func which doesn't convey any information about the property. Look at http://facebook.github.io/react/docs/reusable-components.html and https://github.com/HurricaneJames/react-immutable-proptypes |
Have you looked into custom type validation? Let me know if the following is what you're looking for. cortexTypeOf(cortex, propType) {
// this may be a little simplistic and need to be improved.
// you can also create a bunch of helpers that are built on top of this function.
// like cortexType.isNumber, cortexType.isString, etc.
// ultimately this could become a lib similar to react-immutable-proptypes but for cortex.
return typeof cortex.getValue() === propType;
} myCortexProp: function(props, propName, componentName) {
if (!cortexTypeOf(props[propName], yourPropType) {
return new Error('Validation failed!');
}
} |
Yes, this is what I need! |
I'm closing this since there's a solution and it isn't a core problem in cortex |
I would like to use propTypes (or some other type validation) together with cortex. Is there any way to do that currently without having to also specify __values?
The text was updated successfully, but these errors were encountered: