ExamplesSimple

Hello World

import {useObservable} from 'react-rx'
import {of} from 'rxjs'

const observable = of('World')

export default function App() {
  const data = useObservable(observable)

  return <h1>Hello, {data}!</h1>
}

Open on CodeSandboxOpen Sandbox

Counter

import {useObservable} from 'react-rx'
import {timer} from 'rxjs'

const observable = timer(0, 1000)

export default function App() {
  const seconds = useObservable(observable)
  return <>Seconds: {seconds}</>
}

Open on CodeSandboxOpen Sandbox