David Weldon David Weldon - 2 months ago 23
React JSX Question

React prop validation for date objects

What is the currently preferred way to validate a

Date
prop in react?

Right now I'm using:
React.PropTypes.object


This, however, is now failing the forbid-prop-types lint rule. Should I use a
shape
or is there some better way?

Answer

Pretty sure you could use React.PropTypes.instanceOf(Date)