neux - v0.19.0
    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. Writes made inside still count as the effect's own, so they do not re-run it.

      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, label: "Count" });
      const dispose = effect(() => {
      // reads `label` without subscribing
      const label = untrack(() => state.label);
      console.log(`${label}: ${state.count}`);
      });
      // does not trigger the effect
      state.label = "Total";
      // triggers the effect
      state.count += 1;
      // later …
      dispose();