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;
17 lines
550 B
TypeScript
17 lines
550 B
TypeScript
import { storiesOf } from '@storybook/react';
|
|
import * as React from 'react';
|
|
import { BehaviorSubject } from 'rxjs';
|
|
import { useObservable } from '../src';
|
|
import ShowDocs from './util/ShowDocs';
|
|
|
|
const counter$ = new BehaviorSubject(0);
|
|
const Demo = () => {
|
|
const value = useObservable(counter$, 0);
|
|
|
|
return <button onClick={() => counter$.next(value! + 1)}>Clicked {value} times</button>;
|
|
};
|
|
|
|
storiesOf('State|useObservable', module)
|
|
.add('Docs', () => <ShowDocs md={require('../docs/useObservable.md')} />)
|
|
.add('Demo', () => <Demo />);
|