Skip to content

Replacements for prop-types ​

prop-types is no longer maintained, and React 19 no longer runs propTypes checks.

TypeScript ​

TypeScript checks component props before your code runs.

Follow React's TypeScript setup guide, then replace propTypes with TypeScript types:

Before:

javascript
import PropTypes from 'prop-types'

function Greeting({ name }) {
  return <p>Hello, {name}!</p>
}

Greeting.propTypes = {
  name: PropTypes.string
}

After:

typescript
interface GreetingProps {
  name?: string
}

function Greeting({ name }: GreetingProps) {
  return <p>Hello, {name}!</p>
}

React also provides a codemod to help with the conversion:

sh
npx codemod@latest react/prop-types-typescript

After migrating, run your type checker and remove prop-types from your dependencies.

TypeScript does not check values at runtime. If you specificaly need runtime validation, you can use a library like zod.

Released under the MIT License. (c548babd)