You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[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>
0 commit comments