React 19 Concurrent Patterns

React 19 Concurrent Patterns

Guides a React 18 to 19 migration: which concurrent patterns to keep and how to adopt useTransition, Suspense, use(), useOptimistic and Actions.

Skill files4 files

references/

SKILL.md91 lines
1
---
2
name: react19-concurrent-patterns
3
description: 'Preserve React 18 concurrent patterns and adopt React 19 APIs (useTransition, useDeferredValue, Suspense, use(), useOptimistic, Actions) during migration.'
4
---
5
6
# React 19 Concurrent Patterns
7
8
React 19 introduced new APIs that complement the migration work. This skill covers two concerns:
9
10
1. **Preserve** existing React 18 concurrent patterns that must not be broken during migration
11
2. **Adopt** new React 19 APIs worth introducing after migration stabilizes
12
13
## Part 1 Preserve: React 18 Concurrent Patterns That Must Survive the Migration
14
15
These patterns exist in React 18 codebases and must not be accidentally removed or broken:
16
17
### createRoot Already Migrated by the R18 Orchestra
18
19
If the R18 orchestra already ran, `ReactDOM.render` → `createRoot` is done. Verify it's correct:
20
21
```jsx
22
// CORRECT React 19 root (same as React 18):
23
import { createRoot } from 'react-dom/client';
24
const root = createRoot(document.getElementById('root'));
25
root.render(
26
<React.StrictMode>
27
<App />
28
</React.StrictMode>
29
);
30
```
31
32
### useTransition No Migration Needed
33
34
`useTransition` from React 18 works identically in React 19. Do not touch these patterns during migration:
35
36
```jsx
37
// React 18 useTransition unchanged in React 19:
38
const [isPending, startTransition] = useTransition();
39
40
function handleClick() {
41
startTransition(() => {
42
setFilteredResults(computeExpensiveFilter(input));
43
});
44
}
45
```
46
47
### useDeferredValue No Migration Needed
48
49
```jsx
50
// React 18 useDeferredValue unchanged in React 19:
51
const deferredQuery = useDeferredValue(query);
52
```
53
54
### Suspense for Code Splitting No Migration Needed
55
56
```jsx
57
// React 18 Suspense with lazy unchanged in React 19:
58
const LazyComponent = React.lazy(() => import('./LazyComponent'));
59
60
function App() {
61
return (
62
<Suspense fallback={<Spinner />}>
63
<LazyComponent />
64
</Suspense>
65
);
66
}
67
```
68
69
---
70
71
## Part 2 React 19 New APIs
72
73
These are worth adopting in a post-migration cleanup sprint. Do not introduce these DURING the migration stabilize first.
74
75
For full patterns on each new API, read:
76
- **`references/react19-use.md`** the `use()` hook for promises and context
77
- **`references/react19-actions.md`** Actions, useActionState, useFormStatus, useOptimistic
78
- **`references/react19-suspense.md`** Suspense for data fetching (the new pattern)
79
80
## Migration Safety Rules
81
82
During the React 19 migration itself, these concurrent-mode patterns must be **left completely untouched**:
83
84
```bash
85
# Verify nothing touched these during migration:
86
grep -rn "useTransition\|useDeferredValue\|Suspense\|startTransition" \
87
src/ --include="*.js" --include="*.jsx" | grep -v "\.test\."
88
```
89
90
If the migrator touched any of these files, review the changes the migration should only have modified React API surface (forwardRef, defaultProps, etc.), never concurrent mode logic.
91

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

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 14,621 prompts

More by @OpenSourceBuffGuy

See all
Sea turtle carrying floating film studio island prompt image

Sea turtle carrying floating film studio island

Draws a giant sea turtle carrying a floating island film studio through a starry sky, where fairies polish rough film strips into golden film.

image-prompt, nano-banana, 3d-render, cartoon, fantasy-world, creatures, animals, whimsical, dreamy, cinematic, dramatic-lighting, vibrant-colors, bokeh, miniature, widescreen, night-scene, illustration, concept-art, surreal, storytelling, clay-3d

Desert buggy escapes drones past industrial outpost prompt image

Desert buggy escapes drones past industrial outpost

Builds a 15-second desert chase video where a racer in an armored buggy escapes drones past an industrial outpost, using five reference images with set jobs.

video-prompt, hailuo, action, multi-shot, timed-beats, camera-movement, reference-image, character-consistency, negative-prompt, cinematic, sci-fi, cars, landscape, aerial-view, tracking-shot, photorealistic, sound-effects, structured-output, long-form, widescreen

1 view
Cozy Pixel Art Farm Island Village prompt image

Cozy Pixel Art Farm Island Village

Draws a cozy 16-bit pixel-art farming village across six small islands joined by bridges, with exact counts for buildings, animals and crops.

image-prompt, gpt-image, pixel-art, isometric, game-assets, concept-art, maps, worldbuilding, cozy, vibrant-colors, ocean, landscape, wide-shot, widescreen, game-development, video-games, structured-output, whimsical, summer, high-angle, aerial-view, animals, negative-prompt, cityscape

1 view

Reviews

Loading reviews…

Discussion

Loading comments…