只需使用usequery重新加载列表的一个特定实体的数据

发布于 2025-02-11 00:20:43 字数 155 浏览 2 评论 0原文

假设我使用React查询的USEQUERY挂钩加载了一个实体列表。更新此列表的一个实体后,我不希望重新加载整个列表,只有该特定实体的数据。

如何使用usequery钩实现此行为?是否可以指定React查询不应重新加载整个列表并重新加载该特定实体的数据?

感谢您的帮助。

Let's say I load a list of entities using the useQuery hook of React Query. After updating one entity of this list I don't want the whole list to be reloaded, just the data for this specific entity.

How could you implement this behaviour using the useQuery hook? Is it possible to specify that React Query should not reload the whole list and just reload the data for this specific entity?

Thank you for your help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

叫思念不要吵 2025-02-18 00:20:43

您可以使用 queryclient.setquerydata >

并在包含所有实体的缓存上更新您的实体。

You can use queryClient.setQueryData in the function onSuccess

and update your entity on the cache that contains all entity.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文