Gets the React proptype for the given primitive or typed-immutable type.
The following native and typed-immutable types are supported:
- strings,
String
,Typed.String
,Typed.String
instances - numbers,
Number
,Typed.Number
,Typed.String
instances - booleans,
Boolean
,Typed.Boolean
,Typed.Boolean
instances - symbols,
Symbol
,Typed.Symbol
,Typed.Symbol
instances (Requires Symbol to be defined or polyfilled) - arrays,
Array
,Typed.Array
,Typed.Array
instances - regular expressions,
RegExp
,Typed.RegExp
,Typed.RegExp
instances - dates,
Date
,Typed.Date
,Typed.Date
instances Record
typesMap
typesUnion
typesMaybe
typesAny
,Typed.Any
The following @brightcove/typed-immutable-extensions types are supported:
Enum
typesMaybe
typesDiscriminator
Kind: global function
Param | Type | Description |
---|---|---|
type | * |
Type to get the proptype for |
Example
import { propTypeOf } from '@brightcove/typed-immutable-proptypes';
const Item = Record({
id: String
});
const ItemList = List(Item);
const ValueType = Union(Item, String);
class MyComponent extends React.Component {
static propTypes = {
item: propTypeOf(Item),
list: propTypeOf(List),
value: propTypeOf(ValueType),
};
render () {
...
}
}