Skip to content

Instantly share code, notes, and snippets.

@kivircik-parantez
Created January 8, 2023 18:01
Show Gist options
  • Save kivircik-parantez/5451f226c368ee7a5a5143d1d1e356f8 to your computer and use it in GitHub Desktop.
Save kivircik-parantez/5451f226c368ee7a5a5143d1d1e356f8 to your computer and use it in GitHub Desktop.
Configure Store
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