1
0
mc-music-pack-creator/client/src/store/index.ts

23 lines
788 B
TypeScript

import { configureStore } from '@reduxjs/toolkit'
import discsReducer from './discs'
import { TypedUseSelectorHook, useDispatch, useSelector } from 'react-redux'
const store = configureStore({
reducer: {
discs: discsReducer
}
})
// Infer the `RootState` and `AppDispatch` types from the store itself
export type RootState = ReturnType<typeof store.getState>
// Inferred type: {posts: PostsState, comments: CommentsState, users: UsersState}
export type AppDispatch = typeof store.dispatch
export const useAppDispatch = () => useDispatch<AppDispatch>()
export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector
// Other code such as selectors can use the imported `RootState` type
export const selectDiscs = (state: RootState) => state.discs
export default store