Cro*_*csx 5 signals reactjs graphql react-hooks
我有一个在严格模式下使用 React 和 GraphQL 的项目。
我更新了一些包,现在在包含异步调用的 useEffect 中收到以下错误。
useEffect(() => {
const loadTags = async () => {
const { data } = await fetchTags();
setTags([...(data?.tags || [])]);
};
loadTags();
}, [current, fetchTags]);
Run Code Online (Sandbox Code Playgroud)
DOMException:信号在异步调用的 useEffect 中无故中止。
我不太确定是什么原因造成的,我相信使用效果会重新运行并自行清除,并且它不会正确中止查询。
以前没有发生过这种情况,或者至少没有产生错误。
我想知道我的实现是否不正确,或者我更新的某些包是否出现问题,我在 github 上找不到我更新的包的任何相关线程
在使用时将@apollo/client库从版本升级3.7.1到后,我也遇到了同样的问题(可能与 相同)。3.7.8useLazyQueryuseQuery
该错误是随版本引入的3.7.4。
在 Apollo 提供修复之前,解决方案是降级到 <= 版本3.7.3。
这是堆栈跟踪(仅供参考):
useLazyQuery.ts:78 Uncaught (in promise) DOMException: signal is aborted without reason
at http://localhost:3000/node_modules/.vite/deps/@apollo_client.js?v=d5c2e0d9:8702:20
at Set.forEach (<anonymous>)
at http://localhost:3000/node_modules/.vite/deps/@apollo_client.js?v=d5c2e0d9:8701:35
at safelyCallDestroy (http://localhost:3000/node_modules/.vite/deps/chunk-JZ3YVIXN.js?v=8247418e:16737:13)
at commitHookEffectListUnmount (http://localhost:3000/node_modules/.vite/deps/chunk-JZ3YVIXN.js?v=8247418e:16864:19)
at invokePassiveEffectUnmountInDEV (http://localhost:3000/node_modules/.vite/deps/chunk-JZ3YVIXN.js?v=8247418e:18359:19)
at invokeEffectsInDev (http://localhost:3000/node_modules/.vite/deps/chunk-JZ3YVIXN.js?v=8247418e:19697:19)
at commitDoubleInvokeEffectsInDEV (http://localhost:3000/node_modules/.vite/deps/chunk-JZ3YVIXN.js?v=8247418e:19678:15)
at flushPassiveEffectsImpl (http://localhost:3000/node_modules/.vite/deps/chunk-JZ3YVIXN.js?v=8247418e:19499:13)
at flushPassiveEffects (http://localhost:3000/node_modules/.vite/deps/chunk-JZ3YVIXN.js?v=8247418e:19443:22)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4308 次 |
| 最近记录: |