React 19: Support for defaultProps will be removed
React 19 ignores defaultProps on function components, so a default becomes undefined. Move defaults into the parameter list and handle null honestly.

Introduction & Quick Summary
A component library upgraded to React 19 renders with empty buttons, and the console shows:
Warning: Support for defaultProps will be removed from function components
in a future major release. Use JavaScript default parameters instead.Quick answer: React 19 stopped reading defaultProps on function components. Move each default into the parameter list, where it also survives destructuring and TypeScript.
// before: ignored in React 19
function Button({ variant, size }) {
return <button className={`${variant} ${size}`} />;
}
Button.defaultProps = { variant: "primary", size: "md" };
// after: applied at call time
function Button({ variant = "primary", size = "md" }) {
return <button className={`${variant} ${size}`} />;
}The warning appears in React 18.3, which added it as a migration aid, and React 19 drops the behaviour entirely. That means a component whose defaults lived in defaultProps does not crash; it renders with undefined where a value used to be. Empty class names, missing placeholders and NaN in calculations follow, often far from the component itself.
Classes are unaffected: static defaultProps on a class component still works in React 19. So do object defaults you write inside the component body. The removal targets one specific pattern, and knowing exactly which one keeps the migration small.
Core Mechanics, Signatures & Reproducible Setup
Reproduce with a component that relies on the old pattern:
npm create vite@latest dp-demo -- --template react-ts
cd dp-demo && npm i && npm i react@19 react-dom@19function Badge({ tone, label }) {
return <span data-tone={tone}>{label}</span>;
}
Badge.defaultProps = { tone: "neutral" };
export default function App() {
return <Badge label="new" />; // data-tone is undefined in React 19
}defaultProps was resolved by createElement, which merged the component's defaultProps into the props object before the component ran. In React 19, createElement no longer looks at defaultProps for function components, so the props object arrives exactly as written at the call site. A default parameter, by contrast, is applied by the JavaScript engine when the destructured property is undefined.
| Component form | defaultProps in React 18 | defaultProps in React 19 | Recommended replacement |
|---|---|---|---|
| Function component | applied | ignored | default parameters |
| Class component | applied | still applied | static defaultProps is fine |
memo(Component) | applied to the inner component | ignored | defaults inside the component |
forwardRef(render) | never applied | never applied | defaults in the render parameters |
lazy(() => import(...)) | applied to the resolved component | ignored | defaults inside the component |
Key Comparison Table
| Approach | Syntax | Default when prop is null | Re-created each render |
|---|---|---|---|
| Default parameter | ({ size = "md" }) | no, null stays null | no |
| Nullish coalescing | const s = size ?? "md" | yes | no |
Component body if | if (!size) size = "md" | yes, also for "" and 0 | no |
defaultProps | C.defaultProps = {...} | not in React 19 | no |
| Default object | ({ items = [] }) | no | yes, a new array per render |
What each component type does with defaults:
| Situation | React 18.3 | React 19 | Action |
|---|---|---|---|
Function component with defaultProps | warns | ignores | migrate to parameters |
Class component with defaultProps | works | works | leave it |
memo wrapper with defaultProps | works, warns | ignores | move defaults inward |
forwardRef with defaultProps | ignores, no warning | ignores | set defaults in the render function |
Library shipping defaultProps | warns in your console | silently ignores | upgrade the library |
Practical Edge Cases, Error Fixes & Deep Dive Code Examples
1. Defaults that depend on other props
A default parameter cannot see the rest of the props object, so dependent defaults move into the body:
function Card({ size = "md", padding = size === "sm" ? 8 : 16, children }) {
return <section style={{ padding }}>{children}</section>;
}This works because destructuring binds left to right, and a later default can reference an earlier binding. When the dependency runs the other way, compute it explicitly:
function Card({ size, padding, children }) {
const resolvedSize = size ?? "md";
const resolvedPadding = padding ?? (resolvedSize === "sm" ? 8 : 16);
return <section style={{ padding: resolvedPadding }}>{children}</section>;
}Reading a prop twice is fine; the failure mode to avoid is a default that silently disagrees with another prop's default.
2. null versus undefined
Default parameters apply only when the argument is undefined. <Input value={null} /> keeps null and skips the default, which matters for controlled inputs:
function Input({ value = "", onChange }) {
return <input value={value} onChange={onChange} />;
}
<Input value={null} /> // React warns about value going null to a string
<Input value={undefined} /> // default applies, value is ""When null must also fall back, use ?? inside the component. || is the wrong operator for numeric or boolean defaults because it replaces 0 and false.
3. memo, forwardRef and lazy
const Row = memo(function Row({ selected = false, children }) {
return <li aria-selected={selected}>{children}</li>;
});
const FancyInput = forwardRef(function FancyInput(
{ placeholder = "Type here", ...rest },
ref,
) {
return <input ref={ref} placeholder={placeholder} {...rest} />;
});memo returns a wrapper object, and React 19 does not forward defaultProps from that wrapper to the inner function. Writing defaults inside the wrapped function covers every wrapper in one move. forwardRef never applied defaultProps in any version, which is why some components have looked broken for years without a warning. Spread props after defaults in JSX so a caller's placeholder still wins.
4. Libraries and design systems
A dependency that still ships defaultProps produces the warning from inside node_modules, and the fix belongs to that package, not your app:
npm ls react
npm outdatedUpgrade the library if a release note mentions React 19 support. When the package is unmaintained, wrap it once instead of patching node_modules:
function LegacyCard(props) {
return <Card {...{ variant: "outlined", ...props }} />;
}The spread order gives the default first and the caller's value second, which reproduces the old behaviour exactly. This wrapper also isolates the workaround so it can be deleted when the package catches up.
5. Class components, PropTypes and typing
static defaultProps on a class keeps working, so a mixed codebase needs no change there:
class Panel extends React.Component {
static defaultProps = { open: false };
render() { return <div hidden={!this.props.open} />; }
}React 19 removed propTypes checking entirely, so a component that relied on PropTypes for defaults never had them: PropTypes only validated. For TypeScript, mark the props optional and let the parameter default narrow the type:
type ButtonProps = { variant?: "primary" | "ghost"; size?: number };
function Button({ variant = "primary", size = 12 }: ButtonProps) {
const v: "primary" | "ghost" = variant; // already narrowed
return <button data-v={v} style={{ fontSize: size }} />;
}TypeScript 5.1 and later infer the default's type into the destructured binding, so an explicit annotation is rarely needed. A package.json diff between the old and new version of a library is often enough to spot the peer range that changed; the JSON formatter makes that comparison readable.
6. Tests, Storybook and server rendering
A test that renders a component with no props exercises the defaults, which is exactly where a React 19 upgrade breaks silently:
import { render, screen } from "@testing-library/react";
test("badge falls back to the neutral tone", () => {
render(<Badge label="new" />);
expect(screen.getByText("new")).toHaveAttribute("data-tone", "neutral");
});Storybook stories that rely on implicit defaults show undefined after the upgrade for the same reason, and server-rendered markup differs from the previous release, so snapshot tests need regenerating once. Treat any snapshot diff that only adds or removes default attribute values as a signal, not noise. Searching a codebase for the pattern is quick with the regex tester: \.defaultProps\s*=.
Common Compilation/Runtime Mistakes & Version Gotchas
Deleting defaultProps without adding defaults. The code compiles and renders undefined; TypeScript only complains if the prop is required. Add the parameter default in the same commit.
Assuming the warning is cosmetic. In React 18.3 it is; in React 19 the values are gone. Upgrade order matters: fix the defaults before moving to 19.
Using || as a replacement. size || "md" turns 0 into "md" and false into the default. Use ?? or a parameter default.
Setting defaults on the exported wrapper. export default memo(Button) then Button.defaultProps sets a property on the memo object, which React never reads. Put defaults inside the function.
Relying on propTypes for defaults. PropTypes.string.isRequired with defaultProps was a common pair; React 19 removes the validation layer, so only the explicit default remains.
Version notes. React 18.3 is the only 18.x release that warns; 18.2 and earlier are silent, which is why a codebase can upgrade to 19 and notice nothing until a screenshot review. React 19 also removed propTypes, string refs, ReactDOM.render and ReactDOM.findDOMNode, so a defaultProps migration usually lands beside those changes. React Native follows the same rule for function components from 0.76 onward.
Reference material: React 19 release notes and Component.
Official references
primary documentationThe React documentation that defines the behaviour this guide explains.
Try matching browser tools
All toolsSmall utilities that fit React work — they run entirely in this browser tab, so nothing you paste leaves your device.
Related React guides
All React guidesReact: Each child in a list should have a unique key prop
Keys tell React which item is which between renders. Use stable ids, avoid index keys and put the key on the mapped element, not on a wrapper.
react-hook-form with zod 4: resolver type errors after the upgrade
Zod 4 split input from output and resolvers v5 re-typed Resolver. Drop the generic, or pass all three, and the errors disappear.
React Profiler API: Measuring Render Timings and Identifying Wasted Re-Renders
actualDuration versus baseDuration, phase names that tell you who triggered a commit, and how to ship the numbers without flooding a backend.
React useOptimistic and useFormStatus: Instant UI Feedback in React 19
Optimistic state that reverts by itself when the Action fails, plus form pending status read from inside the form instead of lifted state.
More in React
All React guidesThe guides filed next to this one in React, in library order.