在redux中dispatch异步action,通常是1写法。但是不理解1和2的区别,求指导!
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.);
慕婉清6462132
相关分类