Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// File: src/redux/index.ts
import { configureStore } from '@reduxjs/toolkit'
import { useDispatch, useSelector, TypedUseSelectorHook } from 'react-redux'
import { createBrowserHistory } from 'history'
import rootReducer from './rootReducer'
export const history = createBrowserHistory()
const store = configureStore({
reducer: rootReducer(history),
// middleware: getDefaultMiddleware => getDefaultMiddleware(), // .prepend(middleware)
})
export type RootState = ReturnType<typeof store.getState>
export type AppDispatch = typeof store.dispatch
export const useReduxDispatch = (): AppDispatch => useDispatch<AppDispatch>()
export const useReduxSelector: TypedUseSelectorHook<RootState> = useSelector
export default store
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment