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 // Inferred type: {posts: PostsState, comments: CommentsState, users: UsersState} export type AppDispatch = typeof store.dispatch export const useAppDispatch = () => useDispatch() export const useAppSelector: TypedUseSelectorHook = useSelector // Other code such as selectors can use the imported `RootState` type export const selectDiscs = (state: RootState) => state.discs export default store