Files
Devour/devour_data/docs/untrack.json
T
Tomas Dvorak 898a3c303f update
2026-02-24 10:33:59 +01:00

17 lines
2.3 KiB
JSON

{
"id": "cec3b24053a39083c7fd6670",
"source": "solid:signals",
"type": "github-document",
"title": "untrack",
"content": "---\ntitle: untrack\nuse_cases: \u003e-\n static values, initial values, default props, performance optimization,\n non-reactive access\ntags:\n - tracking\n - performance\n - props\n - reactivity\n - optimization\n - defaults\nversion: '1.0'\ndescription: \u003e-\n Prevent dependency tracking for static values in SolidJS. Optimize performance\n by excluding non-updating props from reactive tracking scope.\n---\n\nIgnores 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 tracking scope.\n\n```tsx title=\"component.tsx\"\nimport { untrack } from \"solid-js\"\n\nexport function Component(props) {\n const value = untrack(() =\u003e props.value)\n\n return \u003cdiv\u003e{value}\u003c/div\u003e\n }\n}\n```\n\n## Initial and Default Values\n\nIt 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.\n\n```tsx tab title=\"initialValue\" {5}\n// component.tsx\nimport { createSignal } from \"solid-js\"\n\nexport function Component(props) {\n const [name, setName] = createSignal(props.initialName)\n\n return \u003cdiv\u003e{name()}\u003c/div\u003e\n }\n}\n```\n\n```tsx tab title=\"defaultValue\" {5}\n// component.tsx\nimport { createSignal } from \"solid-js\"\n\nexport function Component(props) {\n const [name, setName] = createSignal(props.defaultName)\n\n return \u003cdiv\u003e{name()}\u003c/div\u003e\n }\n}\n```",
"url": "https://github.com/solidjs/solid-docs/blob/HEAD/src/routes/reference/reactive-utilities/untrack.mdx",
"metadata": {
"path": "src/routes/reference/reactive-utilities/untrack.mdx",
"repo": "solidjs/solid-docs",
"repo_url": "https://github.com/solidjs/solid-docs.git",
"size": 1599,
"source_type": "github"
},
"hash": "8d8b74f394fb5401c3a5e1bfe50923197051259c7d151fe99ceef4bb09c99ad8",
"timestamp": "2026-02-23T11:43:00.190188077+01:00"
}