Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Next.js and React

ESLint react/prop-types reports a prop as missing in props validation

Error'name' is missing in props validation

Short answer

The react/prop-types rule found a prop your component reads that has no declared type. In plain JavaScript, add a propTypes block. In TypeScript, add the prop to the component's props type. In React 19, propTypes checks are removed from React, so TypeScript is the real fix.

  • Applies to React 19, eslint-plugin-react 7, TypeScript 5.5
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Run ESLint on the one file and read which prop and which line the rule reports.

    npx eslint src/components/Hello.jsx --rule 'react/prop-types: error'
  2. 2Match what you see, then jump to its fix

    1. 1'name' is missing in props validation on a .jsx fileA JavaScript component does not declare its propsFix
    2. 2'name' type is missing in props validation on a .tsx fileA TypeScript props type is missing one of the propsFix
    3. 3The rule is satisfied, yet wrong prop types produce no warning in the consoleThe project is on React 19 and PropTypes no longer runFix

What does the error look like?

  • 'name' is missing in props validation
  • 'lastname' type is missing in props validation
  • react/prop-types

Cause 1 of 3

A JavaScript component does not declare its props

1Check

The rule reports props a function or class component uses without a propTypes entry.

grep -rn "propTypes" src/components/Hello.jsx

2Fix

Declare every prop the component reads. Use PropTypes.node for children.

import PropTypes from 'prop-types';

function Hello({ name }) {
  return <div>Hello {name}</div>;
}
Hello.propTypes = {
  name: PropTypes.string.isRequired,
};

3Verify

Run the linter again on the file.

npx eslint src/components/Hello.jsx

Confirmed by github.com

Did this fix it?

Cause 2 of 3

A TypeScript props type is missing one of the props

1Check

The rule accepts TypeScript as validation, and reports a prop that is read but absent from the type.

grep -n "interface\|type .*Props" src/components/Hello.tsx

2Fix

Add the missing field to the interface or type alias the component uses.

interface Props {
  name: string;
  age: number;
}
function Hello({ name, age }: Props) {
  return <div>Hello {name}, {age}</div>;
}

3Verify

Run the linter and the type check.

npx eslint src/components/Hello.tsx
npx tsc --noEmit

Confirmed by github.com

Did this fix it?

Cause 3 of 3

The project is on React 19 and PropTypes no longer run

1Check

React 19 removed propTypes checks from the React package, and using them is silently ignored.

npm ls react

2Fix

Move to TypeScript for prop checks, use default parameters instead of defaultProps on function components, and turn the rule off for files already typed. The React team offers a codemod for the conversion.

npx codemod@latest react/prop-types-typescript

3Verify

Run the type check; wrong props are now reported at compile time.

npx tsc --noEmit

Confirmed by react.dev

Did this fix it?

How do I stop it coming back?

  • Pick one way to validate props in a project and enforce it.
  • Use default parameter values on function components instead of defaultProps.
  • Keep props types next to the component so a new prop is added in the same edit.
  • In a TypeScript project, turn off react/prop-types for .tsx files if the rule is noisy.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Web apps

TypeScript rejects MUI Data Grid columns that set a type

A TypeScript error inside a column's renderCell callback

A columns array declared without a type is inferred with type as a plain string, which the Data Grid's column type union does not accept.

2 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.