Skip to content

Commit e825c6d

Browse files
authored
docs: align getting started guides (#59188)
1 parent a170e43 commit e825c6d

2 files changed

Lines changed: 40 additions & 40 deletions

File tree

‎docs/react/getting-started.en-US.md‎

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ Ant Design React is dedicated to providing a **good development experience** for
1010

1111
The official guide also assumes that you have intermediate knowledge about HTML, CSS, and JavaScript, and React. If you are just starting to learn front-end or React, it may not be the best idea to use the UI framework as your first step.
1212

13-
Finally, if you are working in a local development environment, please refer to [Scaffolding Guide](https://u.ant.design/guide) to create a new project.
13+
Finally, if you are working in a local development environment, please refer to [Scaffolding Guide](/docs/react/use-with-vite) to create a new project.
1414

1515
---
1616

17-
## Your First Example
17+
## Your First Example {#first-example}
1818

1919
Here is a simple online CodeSandbox demo of an Ant Design component to show the usage of Ant Design React.
2020

@@ -23,17 +23,17 @@ Here is a simple online CodeSandbox demo of an Ant Design component to show the
2323

2424
Follow the steps below to play around with Ant Design yourself:
2525

26-
### 1. Create a CodeSandbox
26+
### 1. Create a CodeSandbox {#create-codesandbox}
2727

2828
Visit https://u.ant.design/reproduce to create a CodeSandbox -- don't forget to press the save button as well to create a new instance.
2929

30-
### 2. Use and modify an antd component
30+
### 2. Use and modify an antd component {#use-antd-component}
3131

3232
If you are working in a local React project, install `antd` first. The CodeSandbox created above already includes this dependency.
3333

3434
<InstallDependencies npm='$ npm install antd --save' yarn='$ yarn add antd' pnpm='$ pnpm install antd --save' bun='$ bun add antd'></InstallDependencies>
3535

36-
Then replace the contents of your application's entry file (for example, `src/index.js`) with the following code. As you can see, there is no difference between antd's components and typical React components.
36+
Then replace the contents of your application's entry file (for example, `src/main.jsx`) with the following code. As you can see, there is no difference between antd's components and typical React components.
3737

3838
```jsx
3939
import React, { useState } from 'react';
@@ -63,22 +63,22 @@ const App = () => {
6363
createRoot(document.getElementById('root')).render(<App />);
6464
```
6565

66-
### 3. Explore more components
66+
### 3. Explore more components {#explore-components}
6767

6868
You can view the list of components in the side menu of the Components page, such as the [Alert](/components/alert) component. Plenty of examples are also provided in the component pages and API documentation as well.
6969

70-
Click the "Open in Editor" icon in the first example to open an editor with source code to use out-of-the-box. Now you can import the `Alert` component into the CodeSandbox:
70+
Click the "Show Code" icon in the first example to expand the source code. Then import the `Alert` component into the previous CodeSandbox:
7171

7272
```diff
7373
- import { DatePicker, message } from 'antd';
7474
+ import { DatePicker, message, Alert } from 'antd';
7575
```
7676

77-
Now add the following jsx inside the `render` function.
77+
Now add the following JSX inside the `App` component.
7878

7979
```diff
80-
<DatePicker onChange={value => this.handleChange(value)} />
81-
<div style={{ marginTop: 20 }}>
80+
<DatePicker onChange={handleChange} />
81+
<div style={{ marginTop: 16 }}>
8282
- Selected Date: {date ? date.format('YYYY-MM-DD') : 'None'}
8383
+ <Alert title="Selected Date" description={date ? date.format('YYYY-MM-DD') : 'None'} />
8484
</div>
@@ -88,30 +88,22 @@ Select a date, and you can see the effect in the preview area on the right:
8888

8989
<img width="420" src="https://gw.alipayobjects.com/zos/antfincdn/JrXptUm1Nz/6b50edc4-3a3c-4b2a-843e-f9f0af2c4667.png" alt="CodeSandbox screenshot" />
9090

91-
OK! Now that you know the basics of using antd components, you are welcome to explore more components in the CodeSandbox. When reporting a bug with ant design, we also strongly recommend using CodeSandbox to provide a reproducible demo as well.
91+
OK! Now that you know the basics of using antd components, you are welcome to explore more components in the CodeSandbox. When reporting a bug with Ant Design, we also strongly recommend using CodeSandbox to provide a reproducible demo as well.
9292

93-
### 4. Next Steps
93+
### 4. Next Steps {#next-steps}
9494

9595
During actual real-world project development, you will most likely need a development workflow consisting of `compile/build/deploy/lint/debug/` deployment. You can read the following documents on the subject or use the following scaffolds and examples provided below:
9696

9797
- [Ant Design Pro](https://pro.ant.design/)
9898
- [create-next-app](https://github.com/ant-design/ant-design-examples/tree/main/examples/with-nextjs-inline-style)
9999
- More scaffolds at [Scaffold Market](https://scaffold.ant.design/)
100100

101-
## Test with Jest
102-
103-
Jest does not support `esm` modules, and Ant Design uses them. In order to test your Ant Design application with Jest you have to add the following to your Jest config :
104-
105-
```json
106-
"transform": { "^.+\\.(ts|tsx|js|jsx)?$": "ts-jest" }
107-
```
108-
109-
## Import on Demand
101+
## Import on Demand {#import-on-demand}
110102

111103
`antd` supports tree shaking of ES modules, so using `import { Button } from 'antd';` would drop js code you didn't use.
112104

113-
## Customize your Workflow
105+
## Customize your Workflow {#customize-workflow}
114106

115-
If you want to customize your workflow, we recommend using [webpack](https://webpack.js.org) or [vite](https://vite.dev/) to build and debug code. You can try out plenty of [boilerplates](https://github.com/enaqx/awesome-react#react-tools) available in the React ecosystem.
107+
If you want to customize your workflow, we recommend using [webpack](https://webpack.js.org) or [Vite](https://vite.dev/) to build and debug code. You can try out plenty of [boilerplates](https://github.com/enaqx/awesome-react#react-tools) available in the React ecosystem.
116108

117109
There are also some [scaffolds](https://scaffold.ant.design/) which have already been integrated into antd, so you can try and start with one of these and even contribute.

‎docs/react/getting-started.zh-CN.md‎

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,34 @@ order: 0
66
title: 快速上手
77
---
88

9-
Ant Design React 致力于提供给程序员**愉悦**的开发体验。
9+
Ant Design React 致力于提供给程序员**愉悦**的开发体验。在开始之前,推荐先学习 [React](https://zh-hans.react.dev/),并正确安装和配置了 [Node.js](https://nodejs.org/zh-cn/) v16 或以上。
1010

11-
> 在开始之前,推荐先学习 [React](https://react.dev),并正确安装和配置了 [Node.js](https://nodejs.org/) v16 或以上。官方指南假设你已了解关于 HTML、CSS 和 JavaScript 的中级知识,并且已经完全掌握了 React 全家桶的正确开发方式。如果你刚开始学习前端或者 React,将 UI 框架作为你的第一步可能不是最好的主意。
11+
官方指南假设你已了解关于 HTML、CSS 和 JavaScript 的中级知识,并且已经完全掌握了 React 全家桶的正确开发方式。如果你刚开始学习前端或者 React,将 UI 框架作为你的第一步可能不是最好的主意。
12+
13+
最后,如果你使用本地开发环境,请参考 [脚手架指南](/docs/react/use-with-vite-cn) 创建新项目。
1214

1315
---
1416

15-
## 第一个例子
17+
## 第一个例子 {#first-example}
1618

1719
这是一个最简单的 Ant Design 组件的在线 CodeSandbox 演示。
1820

1921
<!-- prettier-ignore -->
2022
<code src="./_demo/first-example.tsx">第一个例子</code>
2123

22-
### 1. 创建一个 CodeSandbox
24+
按照以下步骤亲自体验 Ant Design:
25+
26+
### 1. 创建一个 CodeSandbox {#create-codesandbox}
2327

2428
访问 https://u.ant.design/reproduce 创建一个 CodeSandbox 的在线示例,别忘了保存以创建一个新的实例。
2529

26-
### 2. 使用组件
30+
### 2. 使用组件 {#use-antd-component}
31+
32+
如果你在本地 React 项目中开发,请先安装 `antd`。上面创建的 CodeSandbox 已经包含该依赖。
33+
34+
<InstallDependencies npm='$ npm install antd --save' yarn='$ yarn add antd' pnpm='$ pnpm install antd --save' bun='$ bun add antd'></InstallDependencies>
2735

28-
直接用下面的代码替换 `index.js` 的内容,用 React 的方式直接使用 antd 组件。
36+
直接用下面的代码替换应用入口文件(例如 `src/main.jsx`)的内容,用 React 的方式直接使用 antd 组件。
2937

3038
```jsx
3139
import React, { useState } from 'react';
@@ -56,32 +64,32 @@ const App = () => {
5664
<div style={{ marginTop: 16 }}>
5765
当前日期:{date ? date.format('YYYY年MM月DD日') : '未选择'}
5866
</div>
67+
{contextHolder}
5968
</div>
60-
{contextHolder}
6169
</ConfigProvider>
6270
);
6371
};
6472

6573
createRoot(document.getElementById('root')).render(<App />);
6674
```
6775

68-
### 3. 探索更多组件用法
76+
### 3. 探索更多组件用法 {#explore-components}
6977

70-
你可以在组件页面的左侧菜单查看组件列表,比如 [Alert](/components/alert-cn) 组件,组件文档中提供了各类演示,最下方有组件 API 文档可以查阅。在代码演示部分找到第一个例子,点击右下角的图标展开代码。
78+
你可以在组件页面的左侧菜单查看组件列表,比如 [Alert](/components/alert-cn) 组件,组件文档中提供了各类演示,最下方有组件 API 文档可以查阅。
7179

72-
然后依照演示代码的写法,在之前的 CodeSandbox 里修改 `index.js`,首先在 `import` 内引入 Alert 组件:
80+
在代码演示部分找到第一个例子,点击“显示代码”图标查看源码。然后依照演示代码的写法,在之前的 CodeSandbox 中引入 `Alert` 组件:
7381

7482
```diff
7583
- import { ConfigProvider, DatePicker, message } from 'antd';
7684
+ import { ConfigProvider, DatePicker, message, Alert } from 'antd';
7785
```
7886

79-
然后在 `render` 内添加相应的 jsx 代码:
87+
然后在 `App` 组件内添加相应的 JSX 代码:
8088

8189
```diff
82-
<DatePicker onChange={value => this.handleChange(value)} />
90+
<DatePicker onChange={handleChange} />
8391
<div style={{ marginTop: 16 }}>
84-
- 当前日期:{date ? date.format('YYYY-MM-DD') : '未选择'}
92+
- 当前日期:{date ? date.format('YYYY年MM月DD日') : '未选择'}
8593
+ <Alert title="当前日期" description={date ? date.format('YYYY年MM月DD日') : '未选择'} />
8694
</div>
8795
```
@@ -92,20 +100,20 @@ createRoot(document.getElementById('root')).render(<App />);
92100

93101
好的,现在你已经会使用基本的 antd 组件了,你可以在这个例子中继续探索其他组件的用法。如果你遇到组件的 bug,也推荐建一个可重现的 CodeSandbox 来报告 bug。
94102

95-
### 4. 下一步
103+
### 4. 下一步 {#next-steps}
96104

97105
在实际项目开发中,你会遇到构建、调试、代理、打包部署等一系列工程化的需求。你可以阅读后面的文档或者使用以下脚手架和范例:
98106

99107
- [Ant Design Pro](https://pro.ant.design/)
100108
- [create-next-app](https://github.com/ant-design/ant-design-examples/tree/main/examples/with-nextjs-inline-style)
101109
- 更多脚手架可以查看 [脚手架市场](https://scaffold.ant.design/)
102110

103-
## 按需加载
111+
## 按需加载 {#import-on-demand}
104112

105113
`antd` 默认支持基于 ES modules 的 tree shaking,直接引入 `import { Button } from 'antd';` 就会有按需加载的效果。
106114

107-
## 自行构建
115+
## 自行构建 {#customize-workflow}
108116

109-
如果想自己维护工作流,我们推荐使用 [webpack](https://webpack.js.org) 或者 [vite](https://cn.vitejs.dev/) 进行构建和调试,可以使用 React 生态圈中的 [各种脚手架](https://github.com/enaqx/awesome-react#react-tools) 进行开发。
117+
如果想自己维护工作流,我们推荐使用 [webpack](https://webpack.docschina.org/) 或者 [Vite](https://cn.vitejs.dev/) 进行构建和调试,可以使用 React 生态圈中的 [各种脚手架](https://github.com/enaqx/awesome-react#react-tools) 进行开发。
110118

111119
目前社区也有很多基于 antd 定制的 [React 脚手架](https://scaffold.ant.design/),欢迎进行试用和贡献。

0 commit comments

Comments
 (0)