3 ms·
`PropTypes` are a library for runtime type checking of props for React components. It was originally part of the React core, but split out into a separate libr
by acemarke 8y ago
`PropTypes` are a library for runtime type checking of props for React components. It was originally part of the React core, but split out into a separate library with React 16.
PropTypes are used for a combination of debugging during development ("you accidentally passed a string instead of a number", or "you forgot to include a required prop"), as well as documentation for a component. React devs have traditionally used PropTypes to act as readable documentation of a component's expected props, and there are tools that can extract PropTypes usages and generate documentation files.
However, with the rise of TS and Flow as static type systems, the need for a runtime-based type checker has gone down, especially since people using TS/Flow have probably already declared types for a given component's props.