React's experimental `cache` function enables memoization of function results across component renders and even across multiple component instances. Unlike `useMemo`, which is scoped to a single component, `cache` shares memoized results globally within a render tree, making it ideal for expensive computations called by multiple components. The post covers basic usage, comparison with `useMemo` and `memo`, cross-component result caching with a theme generation example, pre-loading async data (e.g., server component data fetching with the `use` hook), and the fact that thrown errors are also memoized. The API is currently only available in React's canary channel.
Sort: