React 19 Source Patterns

React 19 Source Patterns

Lists before and after patterns for migrating source files to React 19: createRoot, hydrateRoot, ref as a prop, defaultProps, legacy context and string refs.

Skill files2 files

references/

SKILL.md38 lines
1
---
2
name: react19-source-patterns
3
description: 'Reference for React 19 source-file migration patterns, including API changes, ref handling, and context updates.'
4
---
5
6
# React 19 Source Migration Patterns
7
8
Reference for every source-file migration required for React 19.
9
10
## Quick Reference Table
11
12
| Pattern | Action | Reference |
13
|---|---|---|
14
| `ReactDOM.render(...)` | → `createRoot().render()` | See references/api-migrations.md |
15
| `ReactDOM.hydrate(...)` | → `hydrateRoot(...)` | See references/api-migrations.md |
16
| `unmountComponentAtNode` | → `root.unmount()` | Inline fix |
17
| `ReactDOM.findDOMNode` | → direct ref | Inline fix |
18
| `forwardRef(...)` wrapper | → ref as direct prop | See references/api-migrations.md |
19
| `Component.defaultProps = {}` | → ES6 default params | See references/api-migrations.md |
20
| `useRef()` no arg | → `useRef(null)` | Inline fix add `null` |
21
| Legacy Context | → `createContext` | [→ api-migrations.md#legacy-context](references/api-migrations.md#legacy-context) |
22
| String refs `this.refs.x` | → `createRef()` | [→ api-migrations.md#string-refs](references/api-migrations.md#string-refs) |
23
| `import React from 'react'` (unused) | Remove | Only if no `React.` usage in file |
24
25
## PropTypes Rule
26
27
Do **not** remove `.propTypes` assignments. The `prop-types` package still works as a standalone validator. React 19 only removes the built-in runtime checking from the React package the package itself remains valid.
28
29
Add this comment above any `.propTypes` block:
30
```jsx
31
// NOTE: React 19 no longer runs propTypes validation at runtime.
32
// PropTypes kept for documentation and IDE tooling only.
33
```
34
35
## Read the Reference
36
37
For full before/after code for each migration, read **`references/api-migrations.md`**. It contains the complete patterns including edge cases for `forwardRef` with `useImperativeHandle`, `defaultProps` null vs undefined behavior, and legacy context provider/consumer cross-file migrations.
38

© GitHub, Inc. · MIT · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 13,409 prompts

More by @OpenSourceBuffGuy

See all
Swordswoman faces colossal robed figure in industrial yard prompt image

Swordswoman faces colossal robed figure in industrial yard

Writes a two-scene, 20-second live-action video prompt in which a swordswoman freezes a colossal figure with realistic ice and shatters him with a finishing slash.

video-prompt, seedance, action, martial-arts, visual-effects, multi-shot, cinematic, character-consistency, timed-beats, negative-prompt, guardrails, structured-output, photorealistic, fantasy-world, japan, camera-movement, slow-motion, blue-hour, widescreen, advanced, long-form, for-filmmakers, sound-effects, creatures, warriors

Overhead portrait of a girl lying in snow prompt image

Overhead portrait of a girl lying in snow

Creates an overhead portrait of a girl in a school blazer lying in fresh snow, using a JSON spec that keeps the reference face and sets camera, outfit and soft overcast light.

image-prompt, json-prompt, nano-banana, reference-image, face-reference, negative-prompt, photorealistic, portrait, woman, close-up, high-angle, winter, soft-lighting, natural-light, bokeh, moody, editorial, vertical-format, muted-colors, limited-palette, film-grain, cinematic, structured-output, for-photographers, for-artists

Morning skincare ritual ending on serum hero shot prompt image

Morning skincare ritual ending on serum hero shot

Produces a 15-second skincare commercial from an uploaded storyboard, with eight timed match-cut shots ending on a serum hero shot.

video-prompt, video-ad, product-video, multi-shot, timed-beats, scene-transitions, camera-movement, macro, reference-image, storyboard, character-consistency, skincare, beauty, advertising, photorealistic, cinematic, natural-light, woman, hailuo, tracking-shot, slow-motion, for-marketers, long-form

Reviews

Loading reviews…

Discussion

Loading comments…