首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >TypeError:(0,_reactTestRenderer.act)不是函数

TypeError:(0,_reactTestRenderer.act)不是函数
EN

Stack Overflow用户
提问于 2022-07-08 16:13:08
回答 1查看 977关注 0票数 1

在测试用例中使用renderHook时,我会得到这个错误。不知道是什么问题。

代码语言:javascript
复制
TypeError: (0 , _reactTestRenderer.act) is not a function

  13 | 
  14 |   it('allows to upload photos through the mutation', async () => {
> 15 |     const { result, nextUpdate } = renderHook(() =>
     |                                    ^
  16 |       usePhotosUpload({
  17 |         photosUploadMutation,
  18 |       }),

  at renderHook (../../../node_modules/react-hooks-testing-library/lib/index.js:151:30)
  at Object._callee$ (__test__/hooks/usePhotosUpload.test.js:15:36)
  at tryCatch (../../../node_modules/regenerator-runtime/runtime.js:62:40)
  at Generator.invoke [as _invoke] (../../../node_modules/regenerator-runtime/runtime.js:296:22)
  at Generator.prototype.(anonymous function) [as next] (../../../node_modules/regenerator-runtime/runtime.js:114:21)
  at asyncGeneratorStep (__test__/hooks/usePhotosUpload.test.js:13:103)
  at _next (__test__/hooks/usePhotosUpload.test.js:15:194)
  at __test__/hooks/usePhotosUpload.test.js:15:364
  at Object.<anonymous> (__test__/hooks/usePhotosUpload.test.js:15:97)
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-07-08 16:13:08

为了解决这个问题,请使react-test-renderer版本与package.json文件中的react版本相同。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72914208

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档