javascript - 将 redux 转换为 redux 工具包
问题描述
在这里反应初学者,通过编码学习,需要一些帮助/建议来将此 Redux 存储转换为 Redux 工具包,这里我使用名为 configureStore 的函数,将其更改为使用来自 '@reduxjs 的'configureStore' 的好方法是什么/toolkit' 这是为了学习,'createRootReducer' 来自我的 reducers.js,它结合了
const createRootReducer = (history) => combineReducers({
articles: articlesReducer,
selection: selectionReducer,
});
将不胜感激任何帮助/建议。我的 store.js:
import { createBrowserHistory } from "history";
import { createStore, compose, applyMiddleware } from "redux";
import thunk from "redux-thunk";
import { routerMiddleware } from "connected-react-router";
import createRootReducer from "./reducers";
export const history = createBrowserHistory();
const storeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
export default function configureStore(preloadedState) {
const store = createStore(
createRootReducer(history),
preloadedState,
storeEnhancers(applyMiddleware(routerMiddleware(history), thunk))
);
return store;
}
解决方案
推荐阅读
- java - 如何使用 Keycloak REST API 使用 SMS OTP 无密码身份验证登录?
- excel - 在使用转换为链接数据类型(股票)命令的行之后,我的 VBA 子例程停止运行
- python - 创建随机 DNA 序列并将其保存为 csv 文件
- html - Select2 引导元素未按预期调整大小
- google-people-api - Google People API createContact(429 资源已用尽(例如检查配额))
- php - 如何使用 mpdf 将两个 pdf 的两半合并为一个
- vba - 试图通过单击按钮调用子程序并收到编译错误:未定义子或函数
- python - SQLAlchemy:尝试使用 bindparam 执行编译语句时出现类型错误
- python - 这段代码可以加快查找字符串邻域的速度吗?
- haskell - 从映射到其关联对的光学