0.1.1 • Published 7 months ago

@tdukart/use-state-set v0.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

use-state-set

A convenience React hook to use JS Sets in a React state.

Usage

import useStateSet from '@tdukart/use-state-set';

function Foo() {
  const [greetings, addGreeting, removeGreeting] = useStateSet(new Set(['hello']));

  return (
    <div>
      <ul>
        {Array.from(greetings).map(greeting => (
          <li key={greeting}>{greeting}</li>
        ))}
      </ul>
      <button onClick={() => addGreeting('hi')}>Add "hi"</button>
      <button onClick={() => removeGreeting('hello')}>Remove "hello"</button>
    </div>
  );
}

Copyright/License

MIT licensed.

Copyright 2023 Todd Dukart.

0.1.1

7 months ago

0.1.0

7 months ago