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 (#1943)
## Summary
**This is part 2 of the React 19 support effort** - updates the Pro
package (RSCProvider and RSCRoute) for React 19 compatibility.
## Changes
### 1. Import Pattern Updates for React 19
**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. Named imports work better with
tree-shaking and are the recommended pattern.
### 2. 'use client' Directives
Added to client-only components:
- ✅ `RSCProvider.tsx` - Context provider (uses hooks)
- ✅ `RSCRoute.tsx` - Route component (uses hooks)
**Why:** React 19's stricter server/client boundary requires explicit
'use client' for components using 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
**Depends on:** PR #1942 (webpack configuration must 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
- ✅ Pro-only changes - doesn't affect OSS package
## Follow-up
1. ✅ PR #1942: Webpack configuration (foundational)
2. ✅ This PR: Pro package changes
3. 🔜 Next: Documentation
## Related
- Part of breaking up #1937 into smaller, focused PRs
- Required for React 19 support
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- Reviewable:start -->
- - -
This change is [<img src="https://reviewable.io/review_button.svg"
height="34" align="absmiddle"
alt="Reviewable"/>](https://reviewable.io/reviews/shakacode/react_on_rails/1943)
<!-- Reviewable:end -->
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **Refactor**
* Optimized internal type signatures and import structure for improved
code organization and consistency.
* **Bug Fixes**
* Enhanced error handling in RSC routing with improved error boundary
lifecycle management, providing better error recovery and display
capabilities.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Co-authored-by: Claude <noreply@anthropic.com>
0 commit comments