【发布时间】:2018-04-21 12:52:34
【问题描述】:
我正在使用 Redux 在 React Native 中编写一个应用程序。当我执行一个操作时,它似乎取代了 store,而不是更新 store,只定义了 reducer 中明确声明的值。
我正在使用来自redux-actions 包的handleActions。一个减速器示例如下所示;
import { handleActions } from 'redux-actions';
export default handleActions({
DOCUMENT_GET_ALL_PENDING: state => ({
isRefreshing: true,
}),
DOCUMENT_GET_ALL_FULFILLED: (state, action) => ({
document: action.payload.documents,
isRefreshing: false,
}),
}, { isRefreshing: false, documents: [] });
例如,当它到达DOCUMENT_GET_ALL_PENDING 时,文档数组被设置为未定义。
这是我的商店创建的样子;
我正在使用redux-promise-middleware、redux-devtools-extension 和thunk 中间件。
const store = createStore(
rootReducer,
defaultState,
composeWithDevTools(applyMiddleware(promiseMiddleware(), thunk)),
);
欢迎任何和所有的帮助或建议。
【问题讨论】:
标签: react-native redux react-redux redux-thunk