Skip to content

Commit 1e68434

Browse files
justin808claude
andauthored
Fix React import to work with esModuleInterop: false (#1946)
## Summary Fixes TypeScript compilation error in `tests/registerServerComponent.client.test.jsx` by changing React imports from default import syntax to namespace import syntax. **Changes:** - Updated `RSCRoute.tsx` to use `import * as React from 'react'` - Updated `RSCProvider.tsx` to use `import * as React from 'react'` **Root Cause:** The project's `tsconfig.json` has `esModuleInterop: false`, but `@types/react` uses `export =` syntax. This combination requires namespace imports (`import * as React`) rather than default imports (`import React`). **Before:** ```typescript import React, { Component, use, type ReactNode } from 'react'; ``` **After:** ```typescript import * as React from 'react'; import { Component, use, type ReactNode } from 'react'; ``` ## Test Plan - [x] Verified `tests/registerServerComponent.client.test.jsx` now passes - [x] Ran all non-RSC tests in react-on-rails-pro package - all passing - [x] Ran linting checks (ESLint, Prettier, RuboCop) - all passing - [x] Pre-commit hooks passed automatically 🤖 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/1946) <!-- Reviewable:end --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Refactor** * Internal code organization improvements with no changes to user-facing functionality or behavior. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Co-authored-by: Claude <noreply@anthropic.com>
1 parent 9cb8915 commit 1e68434

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

packages/react-on-rails-pro/src/RSCProvider.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414

1515
'use client';
1616

17-
import React, { createContext, useContext, type ReactNode } from 'react';
17+
import * as React from 'react';
18+
import { createContext, useContext, type ReactNode } from 'react';
1819
import type { ClientGetReactServerComponentProps } from './getReactServerComponent.client.ts';
1920
import { createRSCPayloadKey } from './utils.ts';
2021

packages/react-on-rails-pro/src/RSCRoute.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616

1717
'use client';
1818

19-
import React, { Component, use, type ReactNode } from 'react';
19+
import * as React from 'react';
20+
import { Component, use, type ReactNode } from 'react';
2021
import { useRSC } from './RSCProvider.tsx';
2122
import { ServerComponentFetchError } from './ServerComponentFetchError.ts';
2223

0 commit comments

Comments
 (0)