本站资源全部免费,回复即可查看下载地址!
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
译者序 ...................................................................................................................................................xiii
前言 .........................................................................................................................................................xv
第 1 章 Hello World ...........................................................................................................................1
1.1 设置 .............................................................................................................................................1
1.2 Hello React World .......................................................................................................................2
1.3 刚才发生了什么 .........................................................................................................................4
1.4 React.DOM.* ................................................................................................................................4
1.5 特殊 DOM 属性..........................................................................................................................7
1.6 React DevTools 浏览器扩展 ......................................................................................................8
1.7 下一步:自定义组件 .................................................................................................................9
第 2 章 组件的生命周期 ................................................................................................................10
2.1 基础 ...........................................................................................................................................10
2.2 属性 ...........................................................................................................................................12
2.3 propTypes ..................................................................................................................................13
2.4 state ............................................................................................................................................16
2.5 带状态的文本框组件 ...............................................................................................................16
2.6 关于 DOM 事件的说明............................................................................................................19
2.6.1 传统的事件处理 ..........................................................................................................20
2.6.2 React 的事件处理 ........................................................................................................21
2.7 props 与 state ..........................................................................................................................21
2.8 在初始化 state 时使用 props:一种反模式 ...........................................................................22
2.9 从外部访问组件 .......................................................................................................................22
2.10 中途改变属性 .........................................................................................................................24
viii | 目录
2.11 生命周期方法 .........................................................................................................................25
2.12 生命周期示例:输出日志记录 .............................................................................................26
2.13 生命周期示例:使用 mixin...................................................................................................28
2.14 生命周期示例:使用子组件 .................................................................................................30
2.15 性能优化:避免组件更新 .....................................................................................................32
2.16 PureRenderMixin.....................................................................................................................34
第 3 章 Excel:一个出色的表格组件.........................................................................................37
3.1 构造数据 ...................................................................................................................................37
3.2 表头循环 ...................................................................................................................................38
3.3 消除控制台的警告信息 ...........................................................................................................40
3.4 添加 <td> 内容 .........................................................................................................................41
3.5 排序 ...........................................................................................................................................44
3.6 排序的视觉提示 .......................................................................................................................46
3.7 编辑数据 ...................................................................................................................................47
3.7.1 可编辑单元格 ..............................................................................................................48
3.7.2 输入字段的单元格 ......................................................................................................50
3.7.3 保存 ..............................................................................................................................50
3.7.4 结论与虚拟 DOM Diff 算法........................................................................................51
3.8 搜索 ...........................................................................................................................................52
3.8.1 状态与界面 ..................................................................................................................54
3.8.2 筛选内容 ......................................................................................................................55
3.8.3 如何改进搜索功能 ......................................................................................................57
3.9 即时回放 ...................................................................................................................................58
3.9.1 如何改进回放功能 ......................................................................................................59
3.9.2 有另一种实现方法吗 ..................................................................................................59
3.10 下载表格数据 .........................................................................................................................59
第 4 章 JSX .......................................................................................................................................62
4.1 Hello JSX ..................................................................................................................................62
4.2 转译 JSX ...................................................................................................................................63
4.3 Babel ..........................................................................................................................................64
4.4 客户端 .......................................................................................................................................64
4.5 关于 JSX 转换 ..........................................................................................................................66
4.6 在 JSX 中使用 JavaScript.........................................................................................................68
4.7 在 JSX 中使用空格 ..................................................................................................................69
4.8 在 JSX 中使用注释 ..................................................................................................................70
4.9 HTML 实体...............................................................................................................................71
4.10 展开属性 .................................................................................................................................73
4.11 在 JSX 中返回多个节点 ........................................................................................................75
目录 | ix
4.12 JSX 和 HTML 的区别 ............................................................................................................77
4.12.1 class 和 for 属性不能用了吗 ................................................................................77
4.12.2 style 属性值是一个对象 ........................................................................................77
4.12.3 闭合标签...................................................................................................................78
4.12.4 用驼峰法命名属性...................................................................................................78
4.13 JSX 和表单 .............................................................................................................................78
4.13.1 onChange 处理器 ......................................................................................................78
4.13.2 value 和 defaultValue 的区别 ...............................................................................79
4.13.3 <textarea> 的值 .......................................................................................................79
4.13.4 <select> 的值 ..........................................................................................................80
4.14 使用 JSX 实现 Excel 组件 .....................................................................................................82
第 5 章 为应用开发做准备 ............................................................................................................83
5.1 一个模板应用 ...........................................................................................................................83
5.1.1 文件和目录 ..................................................................................................................84
5.1.2 index.html .....................................................................................................................85
5.1.3 CSS ...............................................................................................................................86
5.1.4 JavaScript ......................................................................................................................86
5.1.5 更现代化的 JavaScript .................................................................................................86
5.2 安装必备工具 ...........................................................................................................................89
5.2.1 Node.js ..........................................................................................................................90
5.2.2 Browserify ....................................................................................................................90
5.2.3 Babel .............................................................................................................................90
5.2.4 React 相关 ....................................................................................................................91
5.3 开始构建 ...................................................................................................................................91
5.3.1 转译 JavaScript .............................................................................................................91
5.3.2 打包 JavaScript .............................................................................................................92
5.3.3 打包 CSS ......................................................................................................................92
5.3.4 大功告成 ......................................................................................................................92
5.3.5 Windows 版本 ..............................................................................................................93
5.3.6 在开发过程中构建 ......................................................................................................93
5.4 发布 ...........................................................................................................................................94
5.5 更进一步 ...................................................................................................................................95
第 6 章 构建应用 ..............................................................................................................................96
6.1 Whinepad v. 0.0.1 .....................................................................................................................96
6.1.1 基本设置 ......................................................................................................................97
6.1.2 开始编写代码 ..............................................................................................................97
6.2 组件 ...........................................................................................................................................99
6.2.1 设置 ..............................................................................................................................99
x | 目录
6.2.2 组件发现工具 ............................................................................................................100
6.2.3 <Button> 组件 ............................................................................................................101
6.2.4 Button.css ....................................................................................................................102
6.2.5 Button.js ......................................................................................................................103
6.2.6 表单 ............................................................................................................................106
6.2.7 <Suggest> ...................................................................................................................106
6.2.8 <Rating> 组件 ............................................................................................................109
6.2.9 <FormInput>“工厂组件” ..........................................................................................112
6.2.10 <Form> .......................................................................................................................115
6.2.11 <Actions> ..................................................................................................................117
6.2.12 对话框 ......................................................................................................................119
6.3 应用配置 .................................................................................................................................121
6.4 <Excel>:改进的新版本 ........................................................................................................123
6.5 <Whinepad> ..............................................................................................................................131
6.6 总结 .........................................................................................................................................134
第 7 章 lint、Flow、测试与复验 ...............................................................................................136
7.1 package.json ............................................................................................................................136
7.1.1 配置 Babel ..................................................................................................................137
7.1.2 脚本 ............................................................................................................................137
7.2 ESLint......................................................................................................................................138
7.2.1 安装 ............................................................................................................................138
7.2.2 运行 ............................................................................................................................138
7.2.3 规则列表 ....................................................................................................................140
7.3 Flow .........................................................................................................................................140
7.3.1 安装 ............................................................................................................................141
7.3.2 运行 ............................................................................................................................141
7.3.3 注册类型检查 ............................................................................................................141
7.3.4 修复 <Button> ............................................................................................................142
7.3.5 app.js ...........................................................................................................................144
7.3.6 关于 props 和 state 类型检查的更多内容..............................................................145
7.3.7 导出 / 导入类型 .........................................................................................................147
7.3.8 类型转换 ....................................................................................................................148
7.3.9 invariant ...................................................................................................................148
7.4 测试 .........................................................................................................................................150
7.4.1 安装 ............................................................................................................................150
7.4.2 首个测试 ....................................................................................................................151
7.4.3 首个 React 测试 .........................................................................................................152
7.4.4 测试 <Button> 组件 ...................................................................................................153
7.4.5 测试 <Actions> 组件 .................................................................................................157
目录 | xi
7.4.6 更多模拟交互 ............................................................................................................159
7.4.7 测试完整的交互 ........................................................................................................160
7.4.8 代码覆盖率 ................................................................................................................163
第 8 章 Flux .....................................................................................................................................165
8.1 理念 .........................................................................................................................................166
8.2 回顾 Whinepad .......................................................................................................................166
8.3 Store ........................................................................................................................................167
8.3.1 Store 事件 ..................................................................................................................169
8.3.2 在 <Whinepad> 中使用 Store ......................................................................................170
8.3.3 在 <Excel> 中使用 Store ............................................................................................173
8.3.4 在 <Form> 中使用 Store ..............................................................................................174
8.3.5 界定 ............................................................................................................................174
8.4 Action ......................................................................................................................................175
8.4.1 CRUD Action ..............................................................................................................175
8.4.2 搜索与排序 ................................................................................................................176
8.4.3 在 <Whinepad> 中使用 Action ....................................................................................178
8.4.4 在 <Excel> 中使用 Action .........................................................................................179
8.5 Flux 回顾.................................................................................................................................181
8.6 immutable ................................................................................................................................182
8.6.1 immutable 存储数据 ..................................................................................................183
8.6.2 immutable 数据操作 ..................................................................................................184
关于作者 ..............................................................................................................................................187
关于封面 ..............................................................................................................................................187
|
温馨提示:
1、本站所有内容均为互联网收集或网友分享或网络购买,本站不破解、不翻录任何视频!
2、如本帖侵犯到任何版权问题,请立即告知本站,本站将及时予与删除并致以最深的歉意!
3、本站资源仅供本站会员学习参考,不得传播及用于其他用途,学习完后请在24小时内自行删除.
4、本站资源质量虽均经精心审查,但也难保万无一失,若发现资源有问题影响学习请一定及时点此进行问题反馈,我们会第一时间改正!
5、若发现链接失效了请联系管理员,管理员会在2小时内修复
6、如果有任何疑问,请加客服QQ:1300822626 2小时内回复你!