Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 19.1 — What's New in React 19
React · Example 1 of 2 React 19+

Default parameters replace defaultProps on function components

defaultProps was ignored, so name is undefined, and the broken propTypes validator never ran: no warning at all. Classes still support static defaultProps.

React 19 (December 2024) added Actions and the form hooks, use, document metadata, resource loading, ref as a prop and <Context> as a provider, and removed long-deprecated APIs such as ReactDOM.render, string refs, legacy context, propTypes checks and defaultProps on function components; 19.1 and 19.2 added Owner Stacks, <Activity>, useEffectEvent and more.

Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.

Ready for more? This phase has 5 hands-on exercises with automatic checks.

Practice questions

Write the code in the editor, run it, then open the model answer to compare.

01

Rewrite this mount code for React 19: ReactDOM.render(<App />, document.getElementById("root")); and later ReactDOM.unmountComponentAtNode(document.getElementById("root"));.

02

Rewrite function Badge({ color, label }) { … } with Badge.defaultProps = { color: "gray", label: "New" } for React 19.

Explain it without notes

01

What are the headline features of React 19?

02

Which APIs were removed in React 19, and what replaces each?

03

How would you upgrade a large React 18 app to React 19 safely?

04

Why can removing defaultProps support cause bugs that tests miss?

Default parameters replace defaultProps on function components React 19+

Preview

Press Run to see the page.

Console

Nothing logged yet.

Expected console output

Old: Hello, undefined
New: Hello, friend