Releases: forge-42/remix-client-cache
Releases · forge-42/remix-client-cache
v3.0.0
CacheRoute
Wrapper function that wraps your component and provides the loader data to it. It takes two arguments, the component that is wrapped as the first one, and the config options as the second (like the adapter to use).
import { CacheRoute, createClientLoaderCache } from "remix-client-cache";
import type { Route } from "./+types/_index";
// Caches the loader data on the client
export const clientLoader = createClientLoaderCache<Route.ClientLoaderArgs>();
// Wraps the component and provides the loader data to it that gets hot swapped behind the scenes
export default CacheRoute(function Index({ loaderData }: Route.LoaderData) {
const { user } = loaderData;
return (
<div>
{user.name} <hr /> {user.email}
<hr />
{user.username}
<hr />
{user.website} <hr />
{user.description}
</div>
);
})
Full Changelog: v2.1.0...v3.0.0
v2.1.0
What's Changed
- Added createClientLoaderCache utility by @AlemTuzlak in #22
Full Changelog: v2.0.1...v2.1.0
v2.0.1
React 19 support
Supports react 19 now
Full Changelog: v2.0.0...v2.0.1
v2.0.0 -react-router v7 support
v1.1.0
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
v1.0.0
Initial release
Initial release of remix-client-cache
Full Changelog: https://github.com/Code-Forge-Net/remix-client-cache/commits/v1.0.0