-
Notifications
You must be signed in to change notification settings - Fork 50.7k
Closed
Closed
Copy link
Labels
Status: UnconfirmedA potential issue that we haven't yet confirmed as a bugA potential issue that we haven't yet confirmed as a bug
Description
I try to use renderToReadableStream function from react-dom/server in Node.js but there is no such function in package.
React version: 18.2.0
Node.js version 16.15.0 or 18.16.0
Steps To Reproduce
- create
index.mjsfile - insert code:
import { renderToString, renderToReadableStream } from "react-dom/server"; console.log({ renderToString, renderToReadableStream });
- run
node index.mjsin terminal
Link to code example:
The current behavior
Error in terminal:
file:///Users/user/Projects/node-fetch-api-server/index.mjs:1
import { renderToString, renderToReadableStream } from "react-dom/server";
^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Named export 'renderToReadableStream' not found. The requested module 'react-dom/server' 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/server';
const { renderToString, renderToReadableStream } = pkg;
at ModuleJob._instantiate (node:internal/modules/esm/module_job:124:21)
at async ModuleJob.run (node:internal/modules/esm/module_job:190:5)
Node.js v18.16.0The expected behavior
Node.js suupports web streams in experimental mode.
The package react-dom/server must have a function renderToReadableStream according to the documentation:
https://react.dev/reference/react-dom/server/renderToReadableStream
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Status: UnconfirmedA potential issue that we haven't yet confirmed as a bugA potential issue that we haven't yet confirmed as a bug