功能: - 网站收藏管理(添加/编辑/删除/收藏) - 分类管理(支持自定义图标和颜色) - 搜索功能 - 点击统计 - 现代暗色主题 UI 技术栈: - 后端: Python Flask + MySQL - 前端: React + Vite + Tailwind CSS - 数据库: MySQL (192.168.8.160) - 端口: 后端 5003, 前端 5173
61 lines
1.1 KiB
Markdown
61 lines
1.1 KiB
Markdown
# `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
|