- 1、本文档共14页,可阅读全部内容。
- 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
一步一步创建 React_Redux 应用指南
React/Redux
/@rajaraodv/step-by-step-guide-to-building-react-redux-apps-using-mocks-
48ca0f47f9a#.xrl0339vm
Redux React React-Redux
Reducer Action Action Creator StateMiddleware
Redux “React Redux ” React-
Redux React Redux
“mocks” Todo list
app 为创应础应值
这过
为为 Redux
React - JS
Action
Redux - React stateAction
Redux React State Action Redux
BTW Todo Todo
React Redux Todo
1 - Mock
2 -
“”
AddTodo TodoList Filter
Redux Action State
1. DOM State
2. JS Action
3 - state action
state action
AddTodo TodoList Filter Action State
3.1 AddTodo
Todo
”ADD_TODO”
3.2 TodoList
TodoList Todo Todos
Filter Todo
VisibilityFilter
Todo
TOGGLE_TODO
3.3 Filter
Filter
CurrentFilter
Filter
SET_VISIBILITY_FILTER
Redux Action Creator
Action Creator DOM JSON “Action”
Action/
dispatch
4 - Action Action Creator
3 Action ADD_TODO TOGGLE_TODO SET_VISIBILITY_FILTER
action Action Creator
1 //1. Takes the text from AddTodo field and returns proper Action JSON to send to other
components.
2 export const addTodo = (text) = {
3 return {
4 type: ‘ADD_TODO’,
5 id: nextTodoId++,
6 text, //--ES6. same as text:text, in ES5
7 completed: false //-- initially this is set to false
8 }
9 }
10
11 //2. Takes filter string and returns proper Action JSON object to send to other compon
ents.
12 export const setVisibilityFilter = (filter) = {
13 return {
14 type: ‘SET_VISIBILITY_FILTER’,
15 filter
16 }
17 }
18
19 //3. Takes Todo item’s id and returns proper Action JSON object to send to other compo
nents.
20 export const toggleTodo = (id) = {
21 return {
22 type: ‘TOGGLE_TODO’,
23 id
24 }
25 }
Redux
文档评论(0)