-
-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SyntaxError while importing react-dom / react #16
Comments
Minimal way to reproduce error
import { createPortal } from "react-dom";
export default function App() {
return createPortal(<div>Hello</div>, document.body);
}
<-- GET /
file:///home/shinwoo-park/Documents/projects/minitest/dist/rsc/App.js:1
import { createPortal } from 'react-dom';
^^^^^^^^^^^^
SyntaxError: Named export 'createPortal' not found. The requested module 'react-dom' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:
import pkg from 'react-dom';
const { createPortal } = pkg;
at ModuleJob._instantiate (node:internal/modules/esm/module_job:134:21)
at async ModuleJob.run (node:internal/modules/esm/module_job:217:5)
at async ModuleLoader.import (node:internal/modules/esm/loader:316:24)
at async file:///home/shinwoo-park/Documents/projects/minitest/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]_imdrh2fqohes5aqxcu753repva/node_modules/seia.js/dist/worker.js:11:20
--> GET / 500 75ms |
@p-sw Thank you for reporting! I reproduced the same issue, and I will immediately work on it. |
@p-sw It looks like you are trying to use Will you try this instead? 'use client'
import { createPortal } from "react-dom";
export default function App() {
return typeof document !== "undefined" ? createPortal(<div>Hello</div>, document.body) : null
} |
Ah, one more. You need to add {
"compilerOptions": {
"jsx": "react-jsx"
}
} This is required since you manually setup your project with |
Describe the bug
It throws SyntaxError everytime I load localhost:5314.
To Reproduce
Here is a repository I'm working on.
Expected behavior
Success with no error, or throws any error caused by react-router-dom
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: