dillon1000/react
Commit
Browse files ReactPropTypes: add `oneOfType` to support union types
Summary:
e.g.
propTypes: {
foo: React.PropTypes.oneOfType([
React.PropTypes.string,
React.PropTypes.number
]);
}
to do this, I exposed a `.weak` chainable validator that returns instead of throws, e.g.
React.PropTypes.string.isRequired.weak
React.PropTypes.string.weak
which returns true or false. Technically, `React.PropTypes.string.weak.isRequired` also exists, but `oneOfType` will never call it. Might be useful to people creating custom validators though.Changed paths2 files
First-parent comparisonsrc/core/ReactPropTypes.js ModifiedM src/core/__tests__/ReactPropTypes-test.js ModifiedPatch
Files changed
Rendering syntax-highlighted changes…