没有合适的资源?快使用搜索试试~ 我知道了~
Fullstack React
需积分: 9 2 下载量 74 浏览量
2018-03-05
22:23:20
上传
评论
收藏 14.63MB PDF 举报
温馨提示
Stop wasting your time learning React with incomplete and confusing tutorials. There are so many incorrect, confusing, and out-of-date blog articles One tutorial says one thing and another says something completely different. There are too many options There are fifty different boilerplates and a dozen different Flux implementations. Which one is best?
资源推荐
资源详情
资源评论



















Fullstack React
The Complete Book on ReactJS and Friends
Anthony Accomazzo, Ari Lerner, David Guttman, Nate Murray,
Clay Allsopp and Tyler McGinnis
© 2015 - 2017 Fullstack.io

Contents
Book Revision . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Prerelease . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Bug Reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Chat With The Community! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Be notified of updates via Twitter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
We’d love to hear from you! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Your first React Web Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Building Product Hunt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Setting up your development environment . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Code editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Node.js and npm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Browser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Special instruction for Windows users . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Ensure IIS is installed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Getting started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Sample Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Previewing the application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Prepare the app . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Our first component . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
React.createClass() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
JSX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
The developer console . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Babel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
ReactDOM.render() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Our second component . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Making Product data-driven . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
The data model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Using props . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Rendering multiple products . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
React the vote (your app’s first interaction) . . . . . . . . . . . . . . . . . . . . . . . . . 25
Propagating the event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Using state . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Setting state with this.setState() . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

CONTENTS
Updating state . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Congratulations! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
A time-logging app . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Getting started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Previewing the app . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Prepare the app . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Breaking the app into components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
The steps for building React apps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Step 2: Build a static version of the app . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
TimersDashboard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
EditableTimer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
TimerForm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
ToggleableTimerForm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
Timer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Render the app . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Try it out . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Step 3: Determine what should be stateful . . . . . . . . . . . . . . . . . . . . . . . . . . 57
State criteria . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Applying the criteria . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
Step 4: Determine in which component each piece of state should live . . . . . . . . . . . 59
The list of timers and properties of each timer . . . . . . . . . . . . . . . . . . . . . . 59
Whether or not the edit form of a timer is open . . . . . . . . . . . . . . . . . . . . . 60
Visibility of the create form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
Step 5: Hard-code initial states . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
Adding state to TimersDashboard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
Receiving props in EditableTimerList . . . . . . . . . . . . . . . . . . . . . . . . . . 62
Props vs. state . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
Adding state to EditableTimer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
Timer and TimerForm remain stateless . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
Adding state to ToggleableTimerForm . . . . . . . . . . . . . . . . . . . . . . . . . . 64
Step 6: Add inverse data flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
TimerForm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
ToggleableTimerForm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
TimersDashboard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
Updating timers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
Adding editability to Timer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
Updating EditableTimer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
Updating EditableTimerList . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
Defining onEditFormSubmit() in TimersDashboard . . . . . . . . . . . . . . . . . . . 74
Deleting timers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
Adding the event handler to Timer . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78

CONTENTS
Routing through EditableTimer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
Routing through EditableTimerList . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
Implementing the delete function in TimersDashboard . . . . . . . . . . . . . . . . . . 79
Adding timing functionality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
Adding a forceUpdate() interval to Timer . . . . . . . . . . . . . . . . . . . . . . . . 82
Try it out . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
Add start and stop functionality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
Add timer action events to Timer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
Create TimerActionButton . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
Run the events through EditableTimer and EditableTimerList . . . . . . . . . . . . 85
Try it out . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
Methodology review . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
Components & Servers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
Preparation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
server.js . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
The Server API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
text/html endpoint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
JSON endpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
Playing with the API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
Loading state from the server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
Try it out . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
Fetch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
Sending starts and stops to the server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
Sending creates, updates, and deletes to the server . . . . . . . . . . . . . . . . . . . . . . 105
Give it a spin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
Next up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
JSX and the Virtual DOM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
React Uses a Virtual DOM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
Why Not Modify the Actual DOM? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
What is a Virtual DOM? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
Virtual DOM Pieces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
ReactElement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
Experimenting with ReactElement . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
Rendering Our ReactElement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
Adding Text (with children) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
ReactDOM.render() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
JSX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
JSX Creates Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
JSX Attribute Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
剩余739页未读,继续阅读
资源评论


csboat
- 粉丝: 2
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


最新资源
- COMSOL 6.2中1-3压电复合材料厚度共振模态及阻抗相位曲线的有限元仿真建模与优化
- LabVIEW面向对象架构实现模拟树莓派可视化编程:大型项目开发与模块化设计 模块化设计 v2.1
- 材料科学中MD和MC模拟联合应用探索材料微观结构与性能
- 纯电动汽车两档AMT变速箱Simulink模型构建及仿真分析:换挡策略与过程详解
- 深度学习用于雷达和PPG数据的生命体征信号提取及四种神经网络模型的应用 · CNN
- 变频与移相仿真技术在LLC谐振变换器中的应用及优化策略
- 基于脉振高频电压注入法的PMSM矢量控制模型及无位置传感器运行研究
- 永磁同步电机无位置传感器控制:基于IF与龙贝格观测器的Matlab仿真及STM32代码生成 · MatlabSimulink 最新版
- 三相VIENNA整流器的高效仿真研究:基于220V输入、输出电压稳定在800V以内、纹波仅占1%的精细调节与性能优化,以实现0.95以上功率因数及低THD<5%的开关频率控制在20kHz下的Simul
- 航天器姿态滑膜容错控制与飞轮安装偏差及故障研究:MATLAB仿真与文献综述 滑模控制
- 晶体塑性ABAQUS脚本:基于细观力学提取二维三维应力及代表体积单元模型单元体积平均应力和应变的脚本
- 基于改进多目标灰狼算法的微电网调度优化研究与应用
- 基于Matlab的雷达数字信号处理关键技术实现与应用 Pulse Compression
- 基于QRCNN-BiLSTM-MultiAttention的区间预测模型及其Matlab实现与应用
- 智能驾驶AEB系统的联合仿真改进算法:安全距离与TTC切换优化
- 基于Maxwell与Simplorer的电机控制系统联合仿真技术及应用实例
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



安全验证
文档复制为VIP权益,开通VIP直接复制
