mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
6b6d0617ef
Update Rollup and related plugins to their most recent versions + resolve any breaking changes/deprecations/etc along the way. I made each change piece by piece, so the commit history tells a pretty good story of what was changed where/how/why. fixes https://github.com/facebook/react/issues/24894 For the full deepdive/context, see: - https://github.com/facebook/react/issues/24894 The inspiration for this came from @jasonwilliams 's PR for attempting to add sourcemap output support to React's builds: - https://github.com/facebook/react/issues/20186 - https://github.com/facebook/react/pull/21946 But I figured that it would be useful to minimise the scope of changes in that PR, and to modernise the build tooling along the way. If any of these updates rely on a node version later than `10.x`, then the following PR may have to land first, otherwise things might break on AppVeyor: - https://github.com/facebook/react/issues/24891 - https://github.com/facebook/react/pull/24892 Co-authored-by: Sebastian Markbage <sebastian@calyptus.eu>
react-dom
This package serves as the entry point to the DOM and server renderers for React. It is intended to be paired with the generic React package, which is shipped as react to npm.
Installation
npm install react react-dom
Usage
In the browser
import { createRoot } from 'react-dom/client';
function App() {
return <div>Hello World</div>;
}
const root = createRoot(document.getElementById('root'));
root.render(<App />);
On the server
import { renderToPipeableStream } from 'react-dom/server';
function App() {
return <div>Hello World</div>;
}
function handleRequest(res) {
// ... in your server handler ...
const stream = renderToPipeableStream(<App />, {
onShellReady() {
res.statusCode = 200;
res.setHeader('Content-type', 'text/html');
stream.pipe(res);
},
// ...
});
}
API
react-dom
See https://reactjs.org/docs/react-dom.html
react-dom/client
See https://reactjs.org/docs/react-dom-client.html