小编Mic*_*ite的帖子

测试自定义挂钩 - 未包含在行为警告中

我尝试测试自定义挂钩,但收到此警告消息

console.error node_modules/@testing-library/react-hooks/lib/core/console.js:19
    Warning: An update to TestComponent inside a test was not wrapped in act(...).
    
    When testing, code that causes React state updates should be wrapped into act(...):
    
    act(() => {
      /* fire events that update state */
    });
    /* assert on the output */
    
    This ensures that you're testing the behavior the user would see in the browser. 
Run Code Online (Sandbox Code Playgroud)

这是我的自定义钩子

import { useState, useEffect } from 'react'

import io from 'socket.io-client'

import config from './../../../../config'

const useNotificationsSocket = (user) …
Run Code Online (Sandbox Code Playgroud)

testing react-hooks react-custom-hooks

4
推荐指数
1
解决办法
3772
查看次数

标签 统计

react-custom-hooks ×1

react-hooks ×1

testing ×1