How to use the oneOfType function from prop-types
Find comprehensive JavaScript prop-types.oneOfType code examples handpicked from public code repositorys.
94 95 96 97 98 99 100 101 102 103
// You can ensure that your prop is limited to specific values by treating // it as an enum. optionalEnum: PropTypes.oneOf(['News', 'Photos']), // An object that could be one of many types optionalUnion: PropTypes.oneOfType([ PropTypes.string, PropTypes.number, PropTypes.instanceOf(Message) ]),
76 77 78 79 80 81 82 83 84 85
), /** * Loads static html or a uri (with optional headers) in the WebView. */ source: PropTypes.oneOfType([ PropTypes.shape({ /* * The URI to load in the WebView. Can be a local or remote file. */
GitHub: szhsin/react-menu
1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543
onClose: handleClose }))] }); }); process.env.NODE_ENV !== "production" ? Menu.propTypes = /*#__PURE__*/_extends({}, rootMenuPropTypes, uncontrolledMenuPropTypes, { menuButton: propTypes.oneOfType([propTypes.element, propTypes.func]).isRequired }) : void 0; var _excluded$6 = ["aria-label", "className", "disabled", "direction", "label", "openTrigger", "onMenuChange", "isHovering", "instanceRef", "itemRef", "captureFocus", "repositionFlag", "itemProps"], _excluded2$2 = ["ref", "className"];
+ 5 other calls in file
GitHub: jimczj/issue-helper
![jimczj profile picture](/jimczj.png?size=40)
30 31 32 33 34 35 36 37 38 39
)) cb && cb() }) } const stringType = PropTypes.oneOfType([ PropTypes.string.isRequired, PropTypes.shape({ zh: PropTypes.string.isRequired, en: PropTypes.string.isRequired
26 27 28 29 30 31 32 33 34 35 36
width: PropTypes.number, height: PropTypes.number, scale: PropTypes.number, }); const ImageSourcePropType = PropTypes.oneOfType([ ImageURISourcePropType, // Opaque type returned by require('./image.jpg') PropTypes.number, // Multiple sources
GitHub: kelp404/capybara-router
1 2 3 4 5 6 7 8 9 10 11
const PropTypes = require('prop-types'); const singleInstance = require('../single-instance'); module.exports = class Link extends React.PureComponent { static propTypes = { to: PropTypes.oneOfType([ PropTypes.string.isRequired, PropTypes.shape({ name: PropTypes.string.isRequired, params: PropTypes.object,
+ 4 other calls in file
GitHub: d8corp/react-mobx-routing
![d8corp profile picture](/d8corp.png?size=40)
17 18 19 20 21 22 23 24 25 26
exact: PropTypes.bool, replace: PropTypes.bool, scrollFirst: PropTypes.bool, children: PropTypes.node, onMove: PropTypes.func, scrollTo: PropTypes.oneOfType([ PropTypes.number, PropTypes.string, ]), };
822 823 824 825 826 827 828 829 830 831
value: PropTypes.string.isRequired, onCaretPositionChange: PropTypes.func.isRequired, containerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({ current: typeof Element === 'undefined' ? PropTypes.any : PropTypes.instanceOf(Element) })]), children: PropTypes.oneOfType([PropTypes.element, PropTypes.arrayOf(PropTypes.element)]).isRequired }; var styled = createDefaultStyle({ position: 'relative', boxSizing: 'border-box',
+ 31 other calls in file
GitHub: AquaSet/Scratch
897 898 899 900 901 902 903 904 905 906 907
} Preview.propTypes = { assetHost: PropTypes.string.isRequired, // If there's no author, this will be false` authorId: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]), authorThumbnailUrl: PropTypes.string, // If there's no author, this will be false` authorUsername: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]), backpackHost: PropTypes.string,
580 581 582 583 584 585 586 587 588 589 590 591
} } ObjectBlock.propTypes = { viewOnly: PropTypes.oneOfType([PropTypes.bool, PropTypes.number]), active: PropTypes.oneOfType([PropTypes.bool, PropTypes.number]), editable: PropTypes.oneOfType([PropTypes.bool, PropTypes.number]) }; ObjectBlock.defaultProps = {
+ 2 other calls in file
195 196 197 198 199 200 201 202 203 204
</div> ); } } Canvas.propTypes = { visible: PropTypes.oneOfType([PropTypes.bool, PropTypes.number]), viewOnly: PropTypes.oneOfType([PropTypes.bool, PropTypes.number]), bottomPagination: PropTypes.oneOfType([PropTypes.bool, PropTypes.number]), getCanvasRef: PropTypes.func, getContainerRef: PropTypes.func,
+ 3 other calls in file
258 259 260 261 262 263 264 265 266 267
textAlign: PropTypes.oneOf(["left", "center", "justify", "right"]), underline: PropTypes.oneOfType([PropTypes.bool, PropTypes.number]), bold: PropTypes.oneOfType([PropTypes.bool, PropTypes.number]), italic: PropTypes.oneOfType([PropTypes.bool, PropTypes.number]), lineHeight: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), wordSpacing: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), letterSpacing: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), fillColor: PropTypes.string };
+ 5 other calls in file
GitHub: iustins/online-shop
476 477 478 479 480 481 482 483 484 485
outline: PropTypes.bool, rounded: PropTypes.bool, circle: PropTypes.bool, floating: PropTypes.bool, flat: PropTypes.bool, innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.string]), onClick: PropTypes.func, size: PropTypes.string, social: PropTypes.string, children: PropTypes.node,
+ 289 other calls in file
GitHub: saumyatalwani/blogBack
865 866 867 868 869 870 871 872 873 874
}]); return HelmetWrapper; }(React.Component), _class.propTypes = { base: PropTypes.object, bodyAttributes: PropTypes.object, children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]), defaultTitle: PropTypes.string, defer: PropTypes.bool, encodeSpecialCharacters: PropTypes.bool, htmlAttributes: PropTypes.object,
+ 3 other calls in file
162 163 164 165 166 167 168 169 170 171 172 173
}; MapProvider.propTypes = { width: PropTypes.number, height: PropTypes.number, projection: PropTypes.oneOfType([PropTypes.string, PropTypes.func]), projectionConfig: PropTypes.object }; var ComposableMap = function ComposableMap(_ref) {
+ 4 other calls in file
GitHub: nudj/components
16 17 18 19 20 21 22 23 24 25 26
RadioBlockGroup.defaultProps = { styles: {} } RadioBlockGroup.propTypes = { styles: PropTypes.oneOfType([ PropTypes.array, PropTypes.objectOf(CustomPropTypes.style) ]) }
GitHub: romibi/CodingTrain
![romibi profile picture](/romibi.png?size=40)
0 1 2 3 4 5 6 7 8 9
const PropTypes = require('prop-types'); const exact = require('prop-types-exact'); const link = module.exports.link = exact({ title: PropTypes.string.isRequired, author: PropTypes.oneOfType([ PropTypes.shape(exact({ name: PropTypes.string.isRequired, url: PropTypes.string, })),
+ 5 other calls in file
prop-types.default is the most popular function in prop-types (2947 examples)