The untrack primitive allows you to read the current value of a signal inside a reactive context (like createEffect, createComputed, or a React render phase) without subscribing to that signal.
This prevents unwanted re-evaluations, React infinite loops, and over-subscribing to state changes.
In this example, we update a signal and show the latest result (tracked) and what the untracked version is.
By default, any signal read inside a tracking context will automatically bind to it. When that signal updates, the context re-runs. However, there are common scenarios where you only want to read the data, not react to it:
userSignal changes, but you need to include the themeSignal value in the payload without re-firing the event when the theme changes.untrack only disables tracking for the synchronous execution of the callback. If you use await inside the callback, signals read after the await might resume tracking depending on the environment context.untrack accepts an Accessor signal and returns the unsubscribed value at the time of calling.
Count: 0
Untracked: 0
Render Count: 1