Skip to content

Commit aac2abd

Browse files
author
chao.wang
committed
代码优化
1 parent 7efca24 commit aac2abd

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

src/5redux-antd-todolist/TodoList.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class TodoList extends Component {
4747
axios.get('/list.json').then((res) => {
4848
console.log(res);
4949
const data = res.data;
50-
// 调用actionCreator里的异步方法,去改变redux里的state
50+
// 调用actionCreator里的异步方法, 去改变redux里的state
5151
const action = initListAction(data);
5252
store.dispatch(action);
5353

src/6redux-antd-todolist/TodoList.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ class TodoList extends Component {
3737
)
3838
}
3939

40-
////// 异步请求或者复杂的逻辑最好是放在其他地方统一管理,redux-thunk
41-
// redux-thunk使用,将异步代码移到action里
40+
////// 异步请求或者复杂的逻辑最好是放在其他地方统一管理, redux-thunk
41+
// redux-thunk使用, 将异步代码移到action里
4242
componentDidMount() {
4343
//// 通过redux-thunk将Ajax放入了actionCreators里
4444
const action = getTodoList();

src/6redux-antd-todolist/store/actionCreators.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ export const initListAction = (data) => {
3131

3232
// 异步操作redux-thunk
3333
export const getTodoList = () => {
34-
// 使用了redux-thunk就能return函数,可以把异步的ajax放在这里了
35-
// 在actionCreator返回如果是函数式的可直接传入store的dispatch,这样里面就能直接使用了,不必再去引入store等一些列流程
34+
// 使用了redux-thunk就能return函数, 可以把异步的ajax放在这里了
35+
// 在actionCreator返回如果是函数式的可直接传入store的dispatch, 这样里面就能直接使用了, 不必再去引入store等一些列流程
3636
return (dispatch) => {
3737
axios.get('/list.json').then((res) => {
3838
console.log(res);

src/6redux-antd-todolist/store/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// 需要使用redux-thunk等中间件的话,需要引入applyMiddleware,我们说的中间件是redux的中间件,不是react的
2-
// 要使用redux-tools,有需要中间件的话,需要改写调试引入方式,要要用到redux中的compose
1+
// 需要使用redux-thunk等中间件的话,需要引入applyMiddleware, 我们说的中间件是redux的中间件, 不是react的
2+
// 要使用redux-tools, 有需要中间件的话,需要改写调试引入方式, 要要用到redux中的compose
33
import { createStore, applyMiddleware, compose } from 'redux';
44
import reducer from './reducer';
55
// 引入redux-thunk

src/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ import './static/iconfont/iconfont.css';
3232
// 第3个,使用actionCreator创建action,Redux知识点复习补充
3333
// import TodoList from './3redux-antd-todolist/TodoList';
3434
// 第4个,UI组件和容器组件拆分, 无状态组件
35-
import TodoList from './4redux-antd-todolist/TodoList';
35+
// import TodoList from './4redux-antd-todolist/TodoList';
3636
// 第5个,Redux发送异步请求获取数据
3737
// import TodoList from './5redux-antd-todolist/TodoList';
3838
// 第6个,Redux-thunk中间件运行ajax求情发送,中间件概念
39-
// import TodoList from './6redux-antd-todolist/TodoList';
39+
import TodoList from './6redux-antd-todolist/TodoList';
4040
// 第7个,Redux-saga中间件
4141
// import TodoList from './7redux-antd-todolist/TodoList';
4242
// 第8个,Raect_Redux的使用

0 commit comments

Comments
 (0)