neux - v0.17.3
    Preparing search index...

    Function untrack

    • Runs a function without tracking property accesses.

      Reads performed inside the callback will not subscribe the current effect to the accessed properties. Useful for breaking cycles or performing intentional non-reactive reads.

      The context is determined by this, following the same rules as signal.

      Type Parameters

      • T = any

        The type of the returned value.

      Parameters

      • this: void | object

        Reactive context; defaults to the shared global context.

      • fn: () => T

        The function to run outside the tracking system.

      Returns T

      The value returned by fn.

      const state = signal({ count: 0 });
      // reads without subscribing
      const dispose = effect(() => {
      untrack(() => {
      console.log(state.count);
      });
      });
      // triggers the effect
      state.count += 1;
      // later …
      dispose();