只需使用usequery重新加载列表的一个特定实体的数据
假设我使用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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 queryclient.setquerydata >
并在包含所有实体的缓存上更新您的实体。
You can use queryClient.setQueryData in the function
onSuccess
and update your entity on the cache that contains all entity.