hooks icon indicating copy to clipboard operation
hooks copied to clipboard

useRequest + optiions.fetchKey 无限循环问题

Open y2x33 opened this issue 4 years ago • 1 comments

使用场景: 使用 fetchKey 进行并行请求,同时在组件 mount 时触发其中的某一个请求。

复现方式: 在官方例子中添加:

useEffect(()=>{
    run(users[0].id);
}, [run]) // 理论上应该将 run 加入到依赖中,但是就是这个会导致无限循环,去掉依赖可以正常请求,但是不符合 react 规范

y2x33 avatar Jun 24 '21 07:06 y2x33

现在确实有这个问题。

你如果只是初始化的时候,可以先不用加 run。

brickspert avatar Jun 24 '21 11:06 brickspert