mirror of
https://github.com/Dvorinka/Devour.git
synced 2026-06-03 20:13:03 +00:00
update
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"id": "afc22c7ea92458d05f6146af",
|
||||
"source": "solid:signals",
|
||||
"type": "github-document",
|
||||
"title": "revalidation",
|
||||
"content": "---\ntitle: \"Revalidation\"\n---\n\nSince server data can change, Solid Router provides mechanisms to revalidate queries and keep the UI up to date.\n\nThe most common case is **automatic revalidation**.\nAfter an [action](/solid-router/concepts/actions) completes successfully, Solid Router automatically revalidates all active queries on the page.\nFor more details, see the [actions documentation](/solid-router/concepts/actions#automatic-data-revalidation).\n\nFor more fine-grained control, you can trigger revalidation manually with the [`revalidate` function](/solid-router/reference/data-apis/revalidate).\nIt accepts a query key (or an array of keys) to target specific queries.\nEach query exposes two properties for this: `key` and `keyFor`.\n\n- `query.key` is the base key for a query and targets all of its instances.\n Using this key will revalidate all data fetched by that query, regardless of the arguments provided.\n- `query.keyFor(arguments)` generates a key for a specific set of arguments, allowing you to target and revalidate only that particular query.\n\n```tsx\nimport { For } from \"solid-js\";\nimport { query, createAsync, revalidate } from \"@solidjs/router\";\n\nconst getProjectsQuery = query(async () =\u003e {\n\t// ... Fetches a list of projects.\n}, \"projects\");\n\nconst getProjectTasksQuery = query(async (projectId: string) =\u003e {\n\t// ... Fetches a list of tasks for a project.\n}, \"projectTasks\");\n\nfunction Projects() {\n\tconst projects = createAsync(() =\u003e getProjectsQuery());\n\n\tfunction refetchAllTasks() {\n\t\trevalidate(getProjectTasksQuery.key);\n\t}\n\n\treturn (\n\t\t\u003cdiv\u003e\n\t\t\t\u003cbutton onClick={refetchAllTasks}\u003eRefetch all tasks\u003c/button\u003e\n\t\t\t\u003cFor each={projects()}\u003e{(project) =\u003e \u003cProject id={project.id} /\u003e}\u003c/For\u003e\n\t\t\u003c/div\u003e\n\t);\n}\n\nfunction Project(props: { id: string }) {\n\tconst tasks = createAsync(() =\u003e getProjectTasksQuery(props.id));\n\n\tfunction refetchTasks() {\n\t\trevalidate(getProjectTasksQuery.keyFor(props.id));\n\t}\n\n\treturn (\n\t\t\u003cdiv\u003e\n\t\t\t\u003cbutton onClick={refetchTasks}\u003eRefetch tasks for this project\u003c/button\u003e\n\t\t\t\u003cFor each={project.tasks}\u003e{(task) =\u003e \u003cdiv\u003e{task.title}\u003c/div\u003e}\u003c/For\u003e\n\t\t\u003c/div\u003e\n\t);\n}\n```",
|
||||
"url": "https://github.com/solidjs/solid-docs/blob/HEAD/src/routes/solid-router/data-fetching/revalidation.mdx",
|
||||
"metadata": {
|
||||
"path": "src/routes/solid-router/data-fetching/revalidation.mdx",
|
||||
"repo": "solidjs/solid-docs",
|
||||
"repo_url": "https://github.com/solidjs/solid-docs.git",
|
||||
"size": 2104,
|
||||
"source_type": "github"
|
||||
},
|
||||
"hash": "e16d16e11f1d94f8a2bc95fb6d2acaba06cecee11778d3be10e6f50e44687e6c",
|
||||
"timestamp": "2026-02-23T11:43:00.192002827+01:00"
|
||||
}
|
||||
Reference in New Issue
Block a user