说我有以下几点:在动作创建器中访问Redux状态?
export const SOME_ACTION = 'SOME_ACTION';
export function someAction() {
return {
type: SOME_ACTION,
}
}
而在这一行动的创建者,我要访问的全局存储状态(全减速)。它是更好地做到这一点:
import store from '../store';
export const SOME_ACTION = 'SOME_ACTION';
export function someAction() {
return {
type: SOME_ACTION,
items: store.getState().otherReducer.items,
}
}
或本:
export const SOME_ACTION = 'SOME_ACTION';
export function someAction() {
return (dispatch, getState) => {
const {items} = getState().otherReducer;
dispatch(anotherAction(items));
}
}
我可以问一下,是否应该检查状态“加载”的状态,以便在第一个Ajax请求没有完成的时候进行另一个Ajax请求? – JoeTidee