Replies: 1 comment 4 replies
-
useRequest 挂载就会请求,然后获取数据后内部状态更新,render 一次。你 useDeepCompareEffect 里又 refresh 了一次请求,再更新一次,这是预期表现。 想要初次只更新一次,把: useDeepCompareEffect(() => {
refresh();
}, [filter]); 换成: useUpdateEffect(() => {
refresh();
}, [filter.userId]); |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
尝试使用
useDeepCompareEffect
+refresh
实现依赖刷新功能,文档: https://ahooks.js.org/zh-CN/hooks/use-request/refresy-deps组件挂载时,logs:
可以看到
<Example1/>
中的service被调用了两次codesandbox
Beta Was this translation helpful? Give feedback.
All reactions