Redux CombineReducers 和 Redux-toolkit ConfigureStore 有什么区别
what is the difference between Redux CombineReducers and Redux-toolkit ConfigureStore
import { configureStore } from "@reduxjs/toolkit";
import testSlice from "./testSlice";
import {combineReducers} from "redux";
const rootReducer = combineReducers({test: testSlice})
export const store = configureStore({
reducer: rootReducer,
});
哪个更好?用于性能和使用目的。哪个好用?
它们是完全不同的东西。
reducer
选项是 slice reducer 的对象,像 {users : usersReducer, posts : postsReducer}
,configureStore
会通过将此对象传递给 Redux combineReducers
实用程序来自动创建根 reducer .参见 here
RTK configureStore
设置 redux 存储配置,不仅 reducer
,还有中间件、开发工具、预加载状态和增强器。
Redux combineReducers
辅助函数将值是不同归约函数的对象转换为单个归约函数
import { configureStore } from "@reduxjs/toolkit";
import testSlice from "./testSlice";
import {combineReducers} from "redux";
const rootReducer = combineReducers({test: testSlice})
export const store = configureStore({
reducer: rootReducer,
});
哪个更好?用于性能和使用目的。哪个好用?
它们是完全不同的东西。
reducer
选项是 slice reducer 的对象,像 {users : usersReducer, posts : postsReducer}
,configureStore
会通过将此对象传递给 Redux combineReducers
实用程序来自动创建根 reducer .参见 here
RTK configureStore
设置 redux 存储配置,不仅 reducer
,还有中间件、开发工具、预加载状态和增强器。
Redux combineReducers
辅助函数将值是不同归约函数的对象转换为单个归约函数