Description
tcomb-react is a library for checking React component props with tcomb types, as an alternative to PropTypes. Its main default is that props are required, which the README calls a saner choice, since it is easy to forget isRequired. It also checks for unwanted additional props, so a component can reject props it does not declare, and you can turn that check off with the strict option set to false. The README describes a @props decorator for ES7 class components, and a propTypes function for stateless components and for React.createClass in ES5. Types can be a map of names to tcomb types, a tcomb struct or interface, or a refinement of one, and checks can be nested to any depth for finer control. The library can also extract documentation from components, with types and comments, through a parse function. A babel plugin lets you write propTypes as Flow type annotations. tcomb-react builds on the tcomb, tcomb-validation and tcomb-doc libraries. The README says it was tested with React 0.13, 0.14 and 15, and that other versions may work. It is aimed at React developers who want stricter prop checking than the default.…
Highlights
- Props required by default
- Checks for unwanted extra props
- Decorator and propTypes function options
- Babel plugin for Flow annotations
- Extracts component documentation
Ratings & Reviews
No ratings yet
Be the first to rate tcomb-react.
People also visit
tcomb-react FAQ
What is tcomb-react?
A library that checks React component props with tcomb types, as an alternative to PropTypes.
Are props required by default?
Yes. The README says this is a saner default, because it is easy to forget isRequired.
Does it reject extra props?
By default it checks for unwanted additional props. Pass the strict option as false to turn that off.
Which React versions were tested?
The README lists React 0.13, 0.14 and 15 as tested, and says other versions may also work.
How do I use it with a stateless component?
Use the propTypes function. The README shows it with a stateless component and with React.createClass in ES5.
What are the best tcomb-react alternatives?
Popular alternatives to tcomb-react include tcomb-form-native, react-toggle and @rockshin/tao-ui. See all tcomb-react alternatives






















