Skip to content

How to opt-out of re-triggering page-level resources after server action invocation #1555

Answered by OliverGrack
asterikx asked this question in Q&A
Discussion options

You must be logged in to vote

Hello, yes this is possible by manually returning a json/redirect/reload object from the actions you don't want to trigger invalidations for.
In the new docs its explained here: https://docs.solidjs.com/solid-router/reference/data-apis/action#revalidate-specific-cached-keys

Taken from the docs:

const deleteTodo = action(async (formData: FormData) => {
  const id = Number(formData.get("id"))
  await api.deleteTodo(id)
  return json(
  { deleted: id },
  { revalidate: ["getAllTodos", getTodos.key, getTodoByID.keyFor(id)]}
  )

  //or
  return reload({ revalidate: ["getAllTodos", getTodos.key, getTodoByID.keyFor(id)]})

  //or
  return redirect("/", { revalidate: ["getAllTodos", getTodos.key, 

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by asterikx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants