因此,这段代码在我的Reaction js应用程序中运行正常.
import reducers from "./reducer";
import middlewareFunctions from "./middleware";
import { createStore, combineReducers, applyMiddleware } from "redux";
const middleware = (store) => (next) => (action) => {
const fn = Object.keys(middlewareFunctions).find(
(key) => key === action.type
);
if (fn) return middlewareFunctions[fn](store, next, action);
return next(action);
};
export default createStore(
combineReducers(reducers),
{},
applyMiddleware(middleware)
);
然而,当我转换为RESPECT打字脚本时,它显示createStore
已被弃用.
建议使用@reduxjs/toolkit
包中的configureStore
方法,取代createStore
.
我在Redux文档页面上阅读了详细信息:https://redux.js.org/introduction/why-rtk-is-redux-today
但是我仍然在努力理解如何使我的代码适应configureStore
1. Question:为什么在我的React TypeScrip应用程序上不推荐使用createStore,而在React Java应用程序上不推荐使用?
2. Question:现在正确的做法是什么?简单地将createStore切换到figureStore是行不通的.