• Executes the specified function while not tracking reactive items. This is useful for operations that access reactive items without actually depending on them.

    Type Parameters

    • T

    Parameters

    • fn: (() => T)

      The function to execute while not tracking reactive items.

        • (): T
        • Returns T

    Returns T

    The result of executing the function.

    Example

    const a = atom(0);
    const b = atom(0);

    let foo = 0;

    autorun(() => {
    a.value;
    untrack(() => {
    b.value;
    });
    foo++;
    });
    console.log(a.value, b.value, foo); // 0 0 1

    a.value++;
    console.log(a.value, b.value, foo); // 1 0 2
    b.value++;
    console.log(a.value, b.value, foo); // 1 1 2