Skip to content

Latest commit

 

History

History
35 lines (26 loc) · 493 Bytes

README.md

File metadata and controls

35 lines (26 loc) · 493 Bytes

use-set

Use a Set in your React Hooks.

Installation

npm i use-set

Usage

import { useSet } from "use-set";

const List = (props) => {
	const checked = useSet(new Set());

	const toggle = key =>
		checked.has(key)
			? checked.delete(key)
			: checked.add(key);

	return <div>
		{props.list.map(item =>
			<Checkbox
				key={item.key}
				name={item.name}
				checked = {checked.has(item.key)}
				onChange={() => toggle(item.key)}
			/>}
	</div>;

};