Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否可以查询渲染钩子时返回的DOM?
const {current} = renderHook(...) current.querySelector('xxx')
是的,假设您的测试在带有 DOM(例如 jsdom/jest)的环境中运行,并且您有一些东西要查询。
注意:current是renderHook. 您必须result.current改用:
current
renderHook
result.current
const {result} = renderHook(...) result.current.querySelector('xxx')