[]previous and next page

isTracking

Says whether reads are being recorded as dependencies right now.

Says whether reads are being recorded as dependencies right now. Use it to skip subscription work, or to warn, when a primitive is read outside an effect or a memo.

Import#

ts
import { isTracking } from "@shadow-js/core/extend";

Signature#

ts
function isTracking(): boolean

Returns#

true while an effect or a memo runs tracked, false otherwise (module scope, untrack, event handlers).

Examples#

ts
import { untrack, useMemo } from "@shadow-js/core";
import { isTracking } from "@shadow-js/core/extend";

const inMemo = useMemo(() => isTracking());
console.log(inMemo(), untrack(() => isTracking())); // true false