Commit 9a04e55
[React 19] Update OSS package imports for consistency with Pro
This PR updates the open-source package to use the same import pattern
as the Pro package, ensuring consistency across the codebase.
## Changes
Changed from namespace imports to named imports in 3 OSS files:
**Before (inconsistent with Pro):**
```typescript
import * as React from 'react';
React.createElement()
React.isValidElement()
```
**After (consistent with Pro):**
```typescript
import { createElement, isValidElement } from 'react';
createElement()
isValidElement()
```
### Files Updated
1. `packages/react-on-rails/src/createReactOutput.ts`
- `React.createElement` → `createElement`
- `React.isValidElement` → `isValidElement`
- `React.ReactElement` type → `ReactElement` type
2. `packages/react-on-rails/src/handleError.ts`
- `React.createElement` → `createElement`
3. `packages/react-on-rails/src/serverRenderReactComponent.ts`
- `React.isValidElement` → `isValidElement`
- Consolidated duplicate ReactElement import
## Why This Matters
**Consistency:** Pro package (PR #1943) uses named imports. This brings OSS in line.
**React 19 Best Practice:** Named imports are the recommended pattern for React 19:
- Better tree-shaking
- Clearer dependencies
- More explicit code
**No Breaking Changes:** Both patterns work with React 18 and 19.
## Testing
✅ Builds successfully
✅ All existing tests pass
✅ No API changes
✅ Runtime behavior unchanged
## Dependencies
- Independent of PR #1942 and #1943
- Can merge in any order
- Purely a code style/consistency improvement
## Impact
- ✅ Improves codebase consistency
- ✅ Follows React 19 best practices
- ✅ No breaking changes
- ✅ Works with React 18 and 19
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>1 parent 23be9a9 commit 9a04e55
File tree
3 files changed
+8
-9
lines changed- packages/react-on-rails/src
3 files changed
+8
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
10 | | - | |
| 9 | + | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
| 1 | + | |
3 | 2 | | |
4 | 3 | | |
5 | 4 | | |
| |||
69 | 68 | | |
70 | 69 | | |
71 | 70 | | |
72 | | - | |
| 71 | + | |
73 | 72 | | |
74 | 73 | | |
75 | 74 | | |
| |||
0 commit comments