Commit e505e90
[React 19] Update Pro package for React 19 compatibility
This PR updates the React on Rails Pro package to work with React 19's
new import patterns and 'use client' directive requirements.
## Changes
### 1. Import Pattern Updates
Changed from namespace imports to named imports for React 19 compatibility:
**Before (React 18):**
```typescript
import * as React from 'react';
React.createContext()
React.useContext()
```
**After (React 19):**
```typescript
import React, { createContext, useContext, type ReactNode } from 'react';
createContext()
useContext()
```
**Why:** React 19 changed module exports structure. Named imports work better
with tree-shaking and are the recommended pattern.
### 2. 'use client' Directives
Added 'use client' directive to client-only components:
- `RSCProvider.tsx` - Client-side context provider
- `RSCRoute.tsx` - Client-side route component
**Why:** React 19's stricter server/client boundary requires explicit 'use client'
for components that use hooks, context, or browser APIs.
### Files Changed
- `packages/react-on-rails-pro/src/RSCProvider.tsx`
- `packages/react-on-rails-pro/src/RSCRoute.tsx`
## Testing
✅ Server rendering works correctly
✅ Client-side hydration successful
✅ RSC functionality preserved
✅ No breaking changes to API
## Dependencies
Requires PR #1942 (webpack configuration) to be merged first for builds to work.
## Impact
- ✅ Enables React 19 support in Pro package
- ✅ Maintains backward compatibility with React 18
- ✅ No API changes - drop-in compatible
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>1 parent 23be9a9 commit e505e90
File tree
2 files changed
+18
-18
lines changed- packages/react-on-rails-pro/src
2 files changed
+18
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
16 | 18 | | |
17 | 19 | | |
18 | 20 | | |
19 | 21 | | |
20 | | - | |
| 22 | + | |
21 | 23 | | |
22 | | - | |
| 24 | + | |
23 | 25 | | |
24 | 26 | | |
25 | | - | |
| 27 | + | |
26 | 28 | | |
27 | 29 | | |
28 | 30 | | |
| |||
46 | 48 | | |
47 | 49 | | |
48 | 50 | | |
49 | | - | |
| 51 | + | |
50 | 52 | | |
51 | | - | |
| 53 | + | |
52 | 54 | | |
53 | 55 | | |
54 | 56 | | |
| |||
74 | 76 | | |
75 | 77 | | |
76 | 78 | | |
77 | | - | |
| 79 | + | |
78 | 80 | | |
79 | 81 | | |
80 | 82 | | |
| |||
99 | 101 | | |
100 | 102 | | |
101 | 103 | | |
102 | | - | |
| 104 | + | |
103 | 105 | | |
104 | 106 | | |
105 | 107 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | | - | |
17 | 15 | | |
18 | 16 | | |
19 | | - | |
| 17 | + | |
20 | 18 | | |
21 | 19 | | |
22 | 20 | | |
23 | 21 | | |
24 | 22 | | |
25 | 23 | | |
26 | 24 | | |
27 | | - | |
28 | | - | |
| 25 | + | |
| 26 | + | |
29 | 27 | | |
30 | 28 | | |
31 | | - | |
| 29 | + | |
32 | 30 | | |
33 | 31 | | |
34 | 32 | | |
| |||
75 | 73 | | |
76 | 74 | | |
77 | 75 | | |
78 | | - | |
79 | | - | |
80 | | - | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
81 | 79 | | |
82 | 80 | | |
83 | 81 | | |
| |||
88 | 86 | | |
89 | 87 | | |
90 | 88 | | |
91 | | - | |
| 89 | + | |
92 | 90 | | |
93 | 91 | | |
94 | 92 | | |
| |||
0 commit comments