Registry / storage / react-cache

react-cache

JSON →
library2.0.0-alpha.1jsnpmunverified

An experimental caching library for React applications, designed to work with concurrent mode and Suspense for data fetching. Version 2.0.0-alpha.1, published by Facebook for demonstration purposes. It provides a basic cache API (unstable_createResource) that integrates with React's experimental features. Not intended for production use; the API is unstable and likely to change. It has no other key differentiators as it's a reference implementation.

npm install react-cache
INSTALL
IMPORT
SIG · REACT-CACHE
R
react-cache
storagejavascriptv2.0.0-alpha.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

unstable_createResource
import { unstable_createResource } from 'react-cache'
const unstable_createResource = require('react-cache').unstable_createResource
ESM module; CommonJS require works but is atypical for React packages.
unstable_createCache
import { unstable_createCache } from 'react-cache'
Undocumented but exported; may change.
default import (not available)
import * as ReactCache from 'react-cache'
import ReactCache from 'react-cache'
No default export; use namespace import.

Creates a resource for data fetching using Suspense-compatible cache.

import React from 'react'; import { unstable_createResource } from 'react-cache'; const resource = unstable_createResource((id) => { return fetch(`https://api.example.com/data/${id}`).then(res => res.json()); }); function MyComponent({ id }) { const data = resource.read(id); return <div>{data.name}</div>; }
Debug
Known issues
breakingAPI is unstable and will change wildly between versions. Do not use in production.
fix
Use a stable alternative like SWR or React Query for production.
affects: all
deprecatedThe package is deprecated in favor of React's built-in cache API (experimental) and third-party libraries.
fix
Migrate to React.unstable_getCacheForType or use a maintained caching solution.
affects: >=2.0.0-alpha.1
gotchaRequires React version ^16.3.0-alpha.1 or later with concurrent mode features enabled.
fix
Ensure React version meets requirements and enable experimental features.
affects: all
Errors
Common errors & fixes
Module not found: Can't resolve 'react-cache'
Package not installed or missing from package.json
fix
npm install react-cache@2.0.0-alpha.1
TypeError: resource.read is not a function
Using default import instead of named import
fix
Use `import { unstable_createResource } from 'react-cache'`
Warning: React.createCache is not available
React version too old or experimental features not enabled
fix
Upgrade React to ^16.3.0-alpha.1 and enable concurrent mode.
Upgrade
Version history
2.0.0-alpha.1latest on npm
Audit
Dependencies
reactrequiredpeer dependency requiring React ^16.3.0-alpha.1 or later
Agent activity
8 hits · last 30 days
node
8
Resources
react-cache — npm install react-cache · libregistry