Andarist / use-callbag

πŸ‘œ Use callbag as React hook.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

use-callbag

Use callbag as React hook.

Example

import interval from 'callbag-interval'
import map from 'callbag-map'
import pipe from 'callbag-pipe'
import useCallbag from 'use-callbag'

export default function Counter({ initialCount }) {
  const count = useCallbag(initialCount, () =>
    pipe(
      interval(1000),
      map(i => initialCount + i + 1),
    ),
  )
  return <span>{`Counter: ${count}`}</span>
}

About

πŸ‘œ Use callbag as React hook.


Languages

Language:JavaScript 100.0%