Question presented to candidate:
"What is PropTypes, and when would you reach for it today?"
What a strong answer should cover:
- PropTypes was React's runtime prop type-checking mechanism: attach a
propTypesobject and React warns in the console when a prop has the wrong type. - It ran in development only and was always a warning, never an error — it never blocked a render.
- The history matters:
React.PropTypesmoved out to the standaloneprop-typespackage in React 15.5. - The key fact: React 19 removed propType checking entirely. A
propTypesobject on a component is now silently ignored — no validation, no warning. defaultPropswas likewise removed for function components in React 19, in favour of ES6 default parameters. Class components keep it.- So the honest answer to "when would you use it" is: not in new code. Use TypeScript, which catches the same errors at compile time and across the whole call site.
- The remaining niche: validating data crossing a runtime boundary — API responses, plugin inputs — which is a job for Zod or Valibot, not PropTypes.
Clarifying questions expected:
- "Which React version is this codebase on?" — the answer changes completely at 19.
- "Is the project on TypeScript already?"
Code / implementation expected: Optional. Showing the TypeScript and default-parameter replacement for a propTypes + defaultProps pair is the useful version.