我尝试测试自定义挂钩,但收到此警告消息
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)