import { configureStore } from '@reduxjs/toolkit'
import {useDispatch, useSelector, useStore} from "react-redux";
import {familySlice} from "./family";
// ...

export const store = configureStore({
    reducer: {
        family: familySlice.reducer,
    }
})

// Get the type of our store variable
export type AppStore = typeof store
// Infer the `RootState` and `AppDispatch` types from the store itself
export type RootState = ReturnType<AppStore['getState']>
// Inferred type: {posts: PostsState, comments: CommentsState, users: UsersState}
export type AppDispatch = AppStore['dispatch']

export const useAppDispatch = useDispatch.withTypes<AppDispatch>()
export const useAppSelector = useSelector.withTypes<RootState>()
export const useAppStore = useStore.withTypes<AppStore>()

export const {addUser, removeUser, setUsers} = familySlice.actions;