# `useUpsert` > DEPRECATED! > Use `useList` hook's upsert action instead Superset of [`useList`](./useList.md). Provides an additional method to upsert (update or insert) an element into the list. ## Usage ```jsx import {useUpsert} from 'react-use'; const Demo = () => { const comparisonFunction = (a: DemoType, b: DemoType) => { return a.id === b.id; }; const [list, { set, upsert, remove }] = useUpsert(comparisonFunction, initialItems); return (
{list.map((item: DemoType, index: number) => (
upsert({ ...item, text: e.target.value })} />
))}
); }; ``` ## Related hooks - [useList](./useList.md)