You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/routes/reference/reactive-utilities/untrack.mdx
+41-3Lines changed: 41 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,11 +2,49 @@
2
2
title: untrack
3
3
---
4
4
5
-
```ts
5
+
Ignores tracking any of the dependencies in the executing code block and returns the value. This helper is useful when a certain `prop` will never update and thus it is ok to use it outside of the reactive context.
6
+
7
+
```tsx title="component.tsx"
6
8
import { untrack } from"solid-js"
7
9
8
-
function untrack<T>(fn: () =>T):T
10
+
exportfunction Component(props) {
11
+
const value =untrack(() =>props.value)
12
+
13
+
return <div>{value}</div>
14
+
}
15
+
}
16
+
```
17
+
18
+
## Initial and Default Values
19
+
20
+
It is not necessary to manually untrack values that are suppose to serve as a default or initial value to a signal. Even with the linter configured to enforce tracking, the linter will accept it when a `prop` is prefixed with `default` or `initial` as it is a common pattern to use them as such.
0 commit comments