在redux中dispatch異步action,通常是1寫法。但是不理解1和2的區(qū)別,求指導(dǎo)!const fetchPosts = (postTitle) => (dispatch, getState) => {
dispatch({ type: 'FETCH_POSTS_REQUEST' }); return fetch(`/some/API/${postTitle}.json`)
.then(response => response.json())
.then(json => dispatch(receivePosts(json)));
};
};//1store.dispatch(fetchPosts('reactjs')).then(() =>
//do sth.);//2fetchPosts('reactjs').then(() =>
//do sth.);
關(guān)于redux中dispatch異步action
有只小跳蛙
2018-08-03 20:12:40