react-rv
    Preparing search index...

    Function useRv

    • Subscribes to a reactive variable and provides its current value, updating the state when the variable is updated.

      Type Parameters

      • T

        The type of the reactive variable's value.

      Parameters

      • rv: Rv<T>

        The reactive variable to subscribe to.

      Returns T

      The current value of the reactive variable.

      import React from 'react'
      import { rv, useRv } from 'react-rv'

      const counter = rv(0)

      const Counter = () => {
      const value = useRv(counter)
      return (
      <div>
      <p>Count: {value}</p>
      <button onClick={() => counter(value + 1)}>Increment</button>
      </div>
      )
      }