decacheClientLoader
New utility passed to clientActions which allow you to clear the clientLoader cache on a successful action submission
import { json, type LoaderFunctionArgs } from "@remix-run/node";
import { ClientLoaderFunctionArgs } from "@remix-run/react";
import { decacheClientLoader, useCachedLoaderData } from "remix-client-cache";
export const loader = async ({ params }: LoaderFunctionArgs) => {
const response = await fetch(
`https://jsonplaceholder.typicode.com/users/${params.user}`
);
const user = await response.json();
await new Promise((resolve) => setTimeout(resolve, 1000));
return json({ user: { ...user, description: Math.random() } });
};
// The data is cached here
export const clientLoader = (args: ClientLoaderFunctionArgs) => cacheClientLoader;
clientLoader.hydrate = true;
// It is de-cached after a successful action submission via the clientAction export
export const clientAction = decacheClientLoader;
What's Changed
- 4 invalidate normal cache on action by @AlemTuzlak in #9
- Follow redirects when swr cache gets a redirect by @AlemTuzlak in #10
New Contributors
- @AlemTuzlak made their first contribution in #9
Full Changelog: v1.0.0...v1.1.0