Writing custom property validators
In this final section, you'll learn how to build your own custom property validation functions and apply them to the property specification. Generally speaking, you should only implement your own property validator if you absolutely have to. The default validators available in prop-types
cover a wide range of scenarios.
However, sometimes, you need to make sure that very specific property values are passed to the component. Remember, these will not be run in production mode, so it's perfectly acceptable for a validator function to iterate over collections. Let's implement some custom validator functions:
function MyComponent({ myArray, myNumber }) { return ( <section> <ul> {myArray.map((i) => ( <li key={i}>{i}</li> &...