1- 这篇快速上手指南会教你如何将TypeScript与[ React] ( http ://facebook.github.io/react /) 结合起来使用。
1+ 这篇快速上手指南会教你如何将TypeScript与[ React] ( https ://reactjs.org /) 结合起来使用。
22在最后,你将学到:
33
44* 使用TypeScript和React创建工程
99我们会使用[ create-react-app] ( https://github.com/facebookincubator/create-react-app ) 工具快速搭建工程环境。
1010
1111这里假设你已经在使用[ Node.js] ( https://nodejs.org/ ) 和[ npm] ( https://www.npmjs.com/ ) 。
12- 并且已经了解了[ React的基础知识] ( https://facebook.github.io/react /docs/hello-world.html ) 。
12+ 并且已经了解了[ React的基础知识] ( https://reactjs.org /docs/hello-world.html ) 。
1313
1414# 安装create-react-app
1515
@@ -146,7 +146,7 @@ function getExclamationMarks(numChars: number) {
146146具体来讲,` Hello ` 是一个函数,接收一个` Props ` 对象并拆解它。
147147如果` Props ` 对象里没有设置` enthusiasmLevel ` ,默认值为` 1 ` 。
148148
149- 使用函数是React中定义组件的[ 两种方式] ( https://facebook.github.io/react /docs/components-and-props.html#functional-and-class-components ) 之一。
149+ 使用函数是React中定义组件的[ 两种方式] ( https://reactjs.org /docs/components-and-props.html#functional-and-class-components ) 之一。
150150如果你喜欢的话,也* 可以* 通过类的方式定义:
151151
152152``` ts
@@ -169,7 +169,7 @@ class Hello extends React.Component<Props, object> {
169169}
170170```
171171
172- 当我们的[ 组件具有某些状态] ( https://facebook.github.io/react /docs/state-and-lifecycle.html ) 的时候,使用类的方式是很有用处的。
172+ 当我们的[ 组件具有某些状态] ( https://reactjs.org /docs/state-and-lifecycle.html ) 的时候,使用类的方式是很有用处的。
173173但在这个例子里我们不需要考虑状态 - 事实上,在` React.Component<Props, object> ` 我们把状态指定为了` object ` ,因此使用SFC更简洁。
174174当在创建可重用的通用UI组件的时候,在表现层使用组件局部状态比较适合。
175175针对我们应用的生命周期,我们会审视应用是如何通过Redux轻松地管理普通状态的。
@@ -464,7 +464,7 @@ export function enthusiasm(state: StoreState, action: EnthusiasmAction): StoreSt
464464你可能想要对reducer写一些测试。
465465因为reducers是纯函数,它们可以传入任意的数据。
466466针对每个输入,可以测试reducers生成的新的状态。
467- 可以考虑使用Jest的[ toEqual] ( https://facebook.github.io/jest/docs/expect.html#toequalvalue ) 方法。
467+ 可以考虑使用Jest的[ toEqual] ( https://facebook.github.io/jest/docs/en/ expect.html#toequalvalue ) 方法。
468468
469469## 创建容器
470470
0 commit comments