Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip cache using useResource hook #50

Open
thomas174 opened this issue Jun 15, 2021 · 1 comment
Open

Skip cache using useResource hook #50

thomas174 opened this issue Jun 15, 2021 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@thomas174
Copy link

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);
@evert evert added the enhancement New feature or request label Jun 15, 2021
@evert evert self-assigned this Jun 15, 2021
@evert
Copy link
Contributor

evert commented Jun 15, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants