feat: 全栈教程站(AI 时代版)——OUTLINE 大纲(skill 配方:靶子先行/步骤分类/积木三句话/指派三样/脱靶/认知基础)+ Vite MPA 七页(书架+六章),跨文档 View Transitions 防闪白(书架相框↔章头共享元素 morph),组件复用 design-lab 孟菲斯×拟物卡
This commit is contained in:
1 parent
9aebbbbde3
commit
690ec5eaf5
101 files changed
+118478
-1
No files matched your search
+60
@@ -0,0 +1,60 @@
|
||||
# `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
|
||||
|
||||
```sh
|
||||
npm install react react-dom
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### In the browser
|
||||
|
||||
```js
|
||||
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
|
||||
|
||||
```js
|
||||
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
|
||||
|
||||
### `react-dom/server`
|
||||
|
||||
See https://reactjs.org/docs/react-dom-server.html
|
||||
Reference in new issue
Block a user