This code will export a new store with the configured reducer and middleware. It will also add a getDefaultMiddleware function to the store. This function will concatenate all the middleware specified in the friendbookApi.middleware property.
Library: react
import { configureStore } from "@reduxjs/toolkit";
import { setupListeners } from "@reduxjs/toolkit/query";
import { friendbookApi } from "./services/friendbookApi";
export const store = configureStore({
reducer: {
[friendbookApi.reducerPath]: friendbookApi.reducer,
},
middleware: (getDefaultMiddleware) =>
getDefaultMiddleware.concat(friendbookApi.middleware),
});
setupListeners(store.dispatch);