Created
January 8, 2023 18:01
-
-
Save kivircik-parantez/5451f226c368ee7a5a5143d1d1e356f8 to your computer and use it in GitHub Desktop.
Configure Store
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { configureStore } from '@reduxjs/toolkit' | |
// Or from '@reduxjs/toolkit/query/react' | |
import { setupListeners } from '@reduxjs/toolkit/query' | |
import { pokemonApi } from './services/pokemon' | |
export const store = configureStore({ | |
reducer: { | |
// Add the generated reducer as a specific top-level slice | |
[pokemonApi.reducerPath]: pokemonApi.reducer, | |
}, | |
// Adding the api middleware enables caching, invalidation, polling, | |
// and other useful features of `rtk-query`. | |
middleware: (getDefaultMiddleware) => | |
getDefaultMiddleware().concat(pokemonApi.middleware), | |
}) | |
// optional, but required for refetchOnFocus/refetchOnReconnect behaviors | |
// see `setupListeners` docs - takes an optional callback as the 2nd arg for customization | |
setupListeners(store.dispatch) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment