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