React state hook that tracks a Set.
import {useSet} from 'react-use';
const Demo = () => {
const [set, { add, has, remove, reset }] = useSet(new Set(['hello']));
return (
<div>
<button onClick={() => add(String(Date.now()))}>Add</button>
<button onClick={() => reset()}>Reset</button>
<button onClick={() => remove('hello')} disabled={!has('hello')}>
Remove 'hello'
</button>
<pre>{JSON.stringify(Array.from(set), null, 2)}</pre>
</div>
);
};