Skip to content

Commit 5876af4

Browse files
author
lewis617
committed
zhushi
1 parent 8f03c5a commit 5876af4

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

redux-examples/async/actions/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ export function invalidateReddit(reddit) {
1818
reddit
1919
}
2020
}
21-
//开始获取action
21+
//开始获取新闻action
2222
function requestPosts(reddit) {
2323
return {
2424
type: REQUEST_POSTS,
2525
reddit
2626
}
2727
}
28-
//获取成功的action
28+
//获取新闻成功的action
2929
function receivePosts(reddit, json) {
3030
return {
3131
type: RECEIVE_POSTS,
@@ -35,7 +35,7 @@ function receivePosts(reddit, json) {
3535
}
3636
}
3737

38-
//获取文章,先触发开始获取action,完成后触发获取成功的action
38+
//获取文章,先触发requestPosts开始获取action,完成后触发receivePosts获取成功的action
3939
function fetchPosts(reddit) {
4040
return dispatch => {
4141
dispatch(requestPosts(reddit))

redux-examples/async/containers/App.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,16 @@ class App extends Component {
1111
this.handleRefreshClick = this.handleRefreshClick.bind(this)
1212
}
1313

14+
//初始化渲染后触发
1415
componentDidMount() {
16+
console.log('执行componentDidMount');
1517
const { dispatch, selectedReddit } = this.props
1618
dispatch(fetchPostsIfNeeded(selectedReddit))
1719
}
1820

21+
//每次接受新的props触发
1922
componentWillReceiveProps(nextProps) {
23+
console.log('执行componentWillReceiveProps',nextProps);
2024
if (nextProps.selectedReddit !== this.props.selectedReddit) {
2125
const { dispatch, selectedReddit } = nextProps
2226
dispatch(fetchPostsIfNeeded(selectedReddit))

0 commit comments

Comments
 (0)