npm install react-types
What does it do?
Instead of this:
var MyComponent = React;// holy crap, glad I don't ever have to write that again...
You can write this:
var types = ;var Shape = typesShape;MyComponent = React;
There is a more feature-packed comparison available.
But of course it's your choice which you would prefer to type.
Prop types: optional versus required?
React makes all propTypes optional by default, which I think is a bad choice. Props are going to be passed to the component whether or not they are specified so everything is optional by default. If I go to the trouble of writing out the propType for a member, it better dam be there.
So, React Types are required by default. However this can be overridden when requiring
react-types or on a prop-by-prop basis.
// global required optionvar types = ;// prop-by-prop basisvar MyComponent = React;
Using PropTypes inside of React Types?
PropTypes has been around way longer than React Types. People have built validation on top of it and have already written their types longhand. To accommodate this situation, React Types allows PropTypes to be placed into it using
types.raw(propType). Examples are best:
var types = ;var MyComponent = React;
What else ya got? (Related projects)
- Reactbone: React extensions for Backbone
- Even More Flux (EMF): Class extensions and integrations for Flux
We can always have more tests: if you find a bug, create an issue or be fabulous and fix the problem and write the tests up yourself in a coherent pull request.
Run tests with the
npm test command.