import useList , { ListActions } from './useList' ; import { IHookStateInitAction } from './misc/hookState' ; export interface UpsertListActions < T > extends Omit < ListActions < T > , 'upsert' > { upsert : ( newItem : T ) => void ; } deprecated export default function useUpsert < T > ( predicate , initialList = [ ] ) { const [ list , listActions ] = useList ( initialList ) ; return [ list , { ... listActions , upsert : ( newItem ) => { listActions . upsert ( predicate , newItem ) ; } , } as UpsertListActions < T > , ] ; }