mirror of
https://github.com/streamich/react-use.git
synced 2026-02-01 14:37:31 +00:00
chore: clean tsconfig.json; feat: updated webpack config to export a function to achieve full-control mode, instead of deprecated Extend Mode;
24 lines
714 B
TypeScript
24 lines
714 B
TypeScript
import { storiesOf } from '@storybook/react';
|
|
import * as React from 'react';
|
|
import { useSet } from '../src';
|
|
import ShowDocs from './util/ShowDocs';
|
|
|
|
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>
|
|
);
|
|
};
|
|
|
|
storiesOf('State|useSet', module)
|
|
.add('Docs', () => <ShowDocs md={require('../docs/useSet.md')} />)
|
|
.add('Demo', () => <Demo />);
|