javascript - Redux thunk,将其用作列表或用作对象之间的区别
问题描述
我正在阅读我在 GitHub 上找到的 react 项目的代码,通过查看 GitHub 上的官方文档,我发现了 redux thunk 的不同用法,他们以这种方式使用它:
import { createStore, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
import rootReducer from './reducers/index';
// Note: this API requires redux@>=3.1.0
const store = createStore(
rootReducer,
applyMiddleware(thunk)
);
但在代码中我发现这个人使用了:
import { AsyncStorage } from 'react-native';
import { applyMiddleware, createStore } from 'redux';
import { autoRehydrate, persistStore } from 'redux-persist'
import thunk from 'redux-thunk';
import reducers from '../reducers';
const middleWare = [thunk];
const createStoreWithMiddleware = applyMiddleware(...middleWare)(createStore);
export default configureStore = (onComplete) => {
const store = autoRehydrate()(createStoreWithMiddleware)(reducers);
persistStore(store, { storage: AsyncStorage }, onComplete);
return store;
};
将它用作列表或对象有什么区别?
解决方案
推荐阅读
- android - 在android中同时运行两个不同的线程
- apache - Traefik - 获取用户 IP
- python - 如何从 csv 文件中获取 Python 中 x 轴上的所有数据
- vb.net - 更改 DataGridViewRow 的轮廓
- c# - Unity C# System.Diagnostics
- javascript - 对 Jaeger 的 Angular 开放跟踪
- javascript - 在 .pug 文件中安装聊天小部件
- c - pow() 函数不适用于 CLion
- mongodb - pymongo 插入大整数
- java - 如何从 pixelmed 获取 C_FIND 中的私有供应商属性标签?