Utilities for working with React Suspense
MIT License
APIs to simplify data loading and caching. Primarily intended for use with React Suspense.
react@experimental
and react-dom@experimental
versions.import { createCache } from "suspense";
const userProfileCache = createCache({
load: async ([userId]) => {
const response = await fetch(`/api/user?id=${userId}`);
return await response.json();
},
});
function UserProfile({ userId }) {
const userProfile = userProfileCache.read(userId);
// ...
}
More examples at suspense.vercel.app.