Trails Packages
    Preparing search index...
    • Creates a new signal with the initial value undefined.

      The initial value will only be applied on the very first call to this hook. The same signal instance will be returned when this hook is called on the next render. This is very similar (in concept) to React's builtin useState hook.

      Type Parameters

      • T

      Returns Reactive<T | undefined>

      function YourComponent() {
      const mySignal = useReactive();
      const someEventHandler = () => {
      // Update the value after some event
      mySignal.value = "new value";
      };

      // Always returns the current value, re-renders if necessary.
      const currentValue = useReactiveValue(mySignal);
      }
    • Creates a new signal with the given initial value.

      Type Parameters

      • T

      Parameters

      • initialValue: T

      Returns Reactive<T>

      ().