Skip to content

invalidate resource from react-cache #14783

@developer239

Description

@developer239

*Question

Link to StackOverflow: https://stackoverflow.com/questions/54558443/unstable-createresource-invalidation-in-react-cache-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 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, if I updated the data on the backend I am currently 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

I know that this library is in active development. However is there some undocumented API that I can use? 🤔

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions