unstable_createResource invalidation in react-cache/suspense

react suspense
react suspense image
react suspense example
react suspense 2019
react suspense axios
react suspense release date
react simple-cache
react suspense source code

How do I invalidate a resource created by react-cache?

I can fetch data from API:

const FooResource = createResource(id => fetch(`/foo/${id}`)); // return a promise, or async/await

// inside render...
const fooResponse = FooResource.read(id); // suspends if not in cache; renders if in cache
return <div> {fooResponse} </div>;

However, when I update the data on the backend I am unable to refetch the data on the frontend.

This is the only somehow official documentation that I was able to find: https://github.com/sw-yx/fresh-concurrent-react/blob/master/apis/react-cache.md

Is there some undocumented API that I can use? 🤔

In general — you can't, and this is why it's "unstable". Don't use it for anything except demos and tinkering. We'll likely replace the whole thing with a different API.

What the heck is this in React ? 🥁🥁(Suspense) 🥁🥁, How do I invalidate a resource created by react-cache? I can fetch data from API: const FooResource = createResource(id => fetch(`/foo/${id}`)); // return a  Wow, it works~ iii. Data Fetching and unstable_createResource. In i Suspense Use Cases, we talked about 2 aspects:. Code Split; Data Fetching; But we don’t give explanation or examples of data

As of now react-cache uses LRU (least recently used) caching policy. By this policy, the least recently used entries are invalidated first.

The size of the cache can be set using function unstable_setGlobalCacheLimit.

I couldn't find a function for explicit cache invalidation in the project. I also think that it is good news, 'cause dealing with cache is generally a hassle. It seems like LRU is going to make it easier for most React users.

Manual cache control might find its way in the future versions of react-cache as more developers embrace the technology and discover new use cases that need a custom approach, but I doubt it's something one should consider for now.

React 16.x Roadmap – React Blog, If you have never heard of Hooks, or any other new API in React, this article will be a How to use Suspense for fetching data; How to use react-cache import { unstable_createResource as createResource } from "react-cache"; function Cache invalidation strategies using IndexedDB in Angular 2+ »  NOTE: The react-cache API is not stable and has changed. Check this issue for more details. Many components in your application will need data that has to be fetched over the network. When that data is loaded, however, you don't want to make a network request because you have the data stored in cache in the browser. React gives us an API to handle cache for us. We can use createCache and

There is a lot more control over the cache is required using react-cache. It seems it is written considering only client-side rendering(though it works on both csr and ssr).

On the server, there are high chances that only a few specific API's need to be cached for a given interval. All user-specific API's or data should not be cached in react-cache.

react-cache should give control to differentiate caching behavior on both client and server as both environments have completely different use cases.

Suspense for Data Fetching (Experimental) – React, React 16.6 with Suspense for Code Splitting (already shipped); A minor (not final API) import {unstable_createResource} from 'react-cache'; // Tell basic features as cache invalidation, and you'll run into a wall very soon. * Add &quot;unstable_&quot; prefix to react-cache createResource and jest-react matchers * Reverted accidental change to error-codes JSON * Remove unstable_ prefix from internal React tests for j

Currently, the react-cache source code doesn't point to any invalidation capability. It makes sense to need invalidation, to update the results for example after you've added a new comment or post, as well as use suspense with post/put/delete requests, which should not be cached by default in the first place.

invalidate resource from `react-cache` · Issue #14783 · facebook , React 16.6 added a <Suspense> component that lets you “wait” for some code to load and declaratively specify a loading Suspense lets your components “wait” for something before they can render. Should caching be global or local? A basic cache for React applications. It also serves as a reference for more advanced caching implementations. This package is meant to be used alongside yet-to-be-released, experimental React features.

The future of React, unfolding with Suspense, unstable_createResource недействительность в react-cache/suspense. Как сделать недействительным ресурс, созданный react-cache ? Я могу извлечь​  You might have heard about features like “Hooks”, “Suspense”, and “Concurrent Rendering” in the previous blog posts and talks. In this post, we’ll look at how they fit together and the expected timeline for their availability in a stable release of React. An Update from August, 2019 You can find an update to this roadmap in the React 16.9 release blog post. tl;dr We plan to split

unstable_createResource недействительность в react-cache , react-cache, 28.02.2020 20:03. React: Cannot ready property 'readContext' of undefined. unstable_createResource invalidation in react-cache/suspense. Stack Overflow Public questions and answers; Teams Private questions and answers for your team; Enterprise Private self-hosted questions and answers for your enterprise; Jobs Programming and related technical career opportunities

Questions and task on the subject:, import { unstable_createResource, } from "react-cache"; const restaurantListResource = unstable_createResource(() => { return new  Ever since the React team released their 16.x vision, it has definitely caught the community by storm. Some of the coolest additions to the collection are Hooks, lazy loading, Suspense, and the cache API.

  • Thank you, of course, I am just playing around with the new API. I will patiently wait for the implementation. 🙂