CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-react

React is a JavaScript library for building user interfaces through a declarative, component-based approach.

Pending
Overview
Eval results
Files

caching.mddocs/

Caching

Server-side caching with request scoping.

cache

function cache<A extends ReadonlyArray<any>, T>(fn: (...args: A) => T): (...args: A) => T;
// Request-scoped cache on server
const getUser = cache(async (id) => {
  const res = await fetch(`/api/users/${id}`);
  return res.json();
});

// Multiple components share cached result
function UserProfile({ userId }) {
  const user = use(getUser(userId));  // Uses cache
  return <div>{user.name}</div>;
}

cacheSignal

function cacheSignal(): AbortSignal | null;
const fetchUser = cache(async (id) => {
  const signal = cacheSignal();
  return fetch(`/api/users/${id}`, { signal });
});

Install with Tessl CLI

npx tessl i tessl/npm-react

docs

built-in-components.md

caching.md

children.md

components.md

composition.md

context.md

development.md

elements.md

experimental.md

hooks-context.md

hooks-effects.md

hooks-imperative.md

hooks-performance.md

hooks-state.md

hooks-transitions.md

index.md

refs.md

transitions.md

tile.json