react-ketting icon indicating copy to clipboard operation
react-ketting copied to clipboard

Skip cache using useResource hook

Open thomas174 opened this issue 4 years ago • 1 comments

Without using the react hooks you can do something like that to skip the cache:

const state = await resource.refresh();

But is it possible to skip the cache using the useResource hook? The example below returns the movie object from the cache.

const client = useClient();
const resource = client.follow("movie", {id: id});
const {loading, error, resourceState, setResourceState} = useResource(resource);

thomas174 avatar Jun 15 '21 14:06 thomas174

Interesting idea. Usually I would recommend to people to try and figure out why they need it (can you invalidate the cache in another way? why does it need to be refreshed?)

However, I think there's valid reasons to want this. For instance, if you expect that the server may have had a state change (perhaps by another user).

So, makes sense to me a s a feature request; and this is something that should probably be extended to other hooks like useCollection

evert avatar Jun 15 '21 16:06 evert