A PropTypes warning says a required prop is undefined
Warning: Failed prop type: The prop `onSave` is marked as required in `Editor`, but its value is `undefined`.Short answer
A component declared a prop with isRequired, and the parent passed nothing or undefined. The warning names the prop and the component. Find the parent that renders it and pass the value, or give the prop a default. In React 19 propTypes are ignored, so the same bug is no longer reported.
Fix it fast
1Find out which cause you have
The warning names a prop and a component. Search for where that component is rendered, then look at the line that should pass the prop.
grep -rn "<Editor" src/2Match what you see, then jump to its fix
- 1
The warning appears on first render, for every use of the component.The parent never passes the prop, or passes a misspelled nameFix - 2
The warning shows only on the first render, and a later render has the value.The value is undefined at first, because it comes from data that is not loaded yetFix - 3
After the upgrade the warning no longer shows, but the prop is still missing.You moved to React 19 and the warnings disappearedFix
- 1
What does the error look like?
Warning: Failed prop type: The prop `onSave` is marked as required in `Editor`, but its value is `undefined`.
Cause 1 of 3
The parent never passes the prop, or passes a misspelled name
1Check
isRequired makes React show a warning if the prop isn't provided. A prop passed under another name counts as missing.
grep -rn "isRequired" src/components/Editor.jsx
grep -rn "<Editor" src/2Fix
Pass the prop with the exact name the component declares.
<Editor onSave={handleSave} />3Verify
Reload the page in development mode and check that the console is quiet.
npm run devConfirmed by github.com
Cause 2 of 3
The value is undefined at first, because it comes from data that is not loaded yet
1Check
A variable read from state, a query result or a route parameter is undefined until it arrives. Passing it straight down sends undefined into a required prop.
console.log('value passed:', handleSave)2Fix
Render the child only when the value exists, or give the prop a default through an ES6 default parameter.
function Editor({ title = 'Untitled', onSave }) {
return <h1 onClick={onSave}>{title}</h1>;
}3Verify
No warning on the first render.
npm run devConfirmed by react.dev
Cause 3 of 3
You moved to React 19 and the warnings disappeared
1Check
React 19 removes propTypes checks from the React package, and they are silently ignored. A missing prop is no longer reported.
npm ls react2Fix
Declare the props in TypeScript instead, so the compiler reports the missing prop. A codemod can convert existing propTypes.
interface EditorProps {
onSave: () => void;
}
function Editor({ onSave }: EditorProps) { /* ... */ }3Verify
tsc reports an error where a parent leaves out onSave.
npx tsc --noEmitConfirmed by react.dev
How do I stop it coming back?
- Type props in TypeScript; propTypes checks are gone in React 19.
- Use default parameters for optional props instead of defaultProps.
- Treat data from queries and routes as possibly undefined before it reaches a component.
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:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- TaskvareA task and project-management suite: React on the web, Flutter on mobile, TypeScript underneath.
Related fixes
Web apps
ESLint react/prop-types reports a prop as missing in props validation
'lastname' type is missing in props validation
The react/prop-types rule found a prop your component reads that has no declared type.
3 causes, each with a fixWeb apps
Module not found for antd/dist/antd.less after upgrading to Ant Design 5
Module not found: Error: Can't resolve 'antd/dist/antd.less'
Ant Design 5 dropped Less and the bundled CSS file for CSS-in-JS, so antd/dist/antd.less no longer exists.
3 causes, each with a fixWeb apps
Astro Code component fails inside a React component
Astro components cannot be rendered directly via function call
Astro components such as Code only exist on the server and render static HTML.
2 causes, each with a fixWeb apps
React shows Attempted import error when importing a component or function
Attempted import error:
The build found the file but not the name you asked for.
2 causes, each with a fixWeb apps
How to catch and handle a 422 from Axios in a Redux thunk
action.error.message is 'Rejected' and action.payload is undefined
A 422 means the server read the request but cannot process its content, so repeating it unchanged fails again.
4 causes, each with a fixWeb apps
axios gets 429 Too Many Requests from a React app
429 (Too Many Requests)
A 429 comes from the server or an API gateway, not from axios: your client sent too many requests in a window.
4 causes, each with a fix