相关疑难解决方法(0)

React Ref 的 offsetheight,即使在加载内容后,对于玩笑测试用例也始终返回“0”

我正在使用react-testing-libraryjest。在 componentdidupdate 中尝试获取“ this.testRef.current.offsetHeight ”,即使在加载内容后,offsetHeight 仍为0 。我想要 DOM 的精确 offsetHeight 因为有一些基于它的条件。

在反应测试库和笑话中是否有任何可能的解决方案可以解决。

我正在使用angerouslySetInnerHTML来绑定testRef 元素的html 内容。

dom reactjs jestjs react-testing-library

14
推荐指数
1
解决办法
1万
查看次数

标签 统计

dom ×1

jestjs ×1

react-testing-library ×1

reactjs ×1