Skip to content

codefeathers/react-use-set

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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>;

};

Releases

No releases published

Packages

No packages published