-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
70 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# `useCallbag` | ||
|
||
React state hook that tracks the latest value of a callbag. | ||
|
||
|
||
## Usage | ||
|
||
```jsx | ||
import {useCallbag} from 'react-use'; | ||
import interval from 'callbag-interval'; | ||
|
||
const Demo = () => { | ||
const count = useCallbag(() => interval(1000)); | ||
return <span>{`Counter: ${count}`}</span> | ||
}; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import {useCallbag} from '..'; | ||
import * as React from 'react'; | ||
import {storiesOf} from '@storybook/react'; | ||
import ShowDocs from '../util/ShowDocs'; | ||
const interval = require('callbag-interval').default; | ||
|
||
const Demo = () => { | ||
const count = useCallbag(() => (interval as any)(1000)); | ||
return <span>{`Counter: ${count}`}</span> | ||
}; | ||
|
||
storiesOf('useCallbag', module) | ||
.add('Docs', () => <ShowDocs md={require('../../docs/useCallbag.md')} />) | ||
.add('Demo', () => | ||
<Demo/> | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import useCallbag from 'use-callbag' | ||
|
||
export default useCallbag; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters