简体   繁体   English

React(16.8.3) document.getElementById() 在 componentDidMount 中返回 null

[英]React(16.8.3) document.getElementById() returning null in componentDidMount

After updating Primereact to 8.3.0 document.getElementById() is returning null for div in primereact accordion created in return of jsx.在将 Primereact 更新到 8.3.0 之后,document.getElementById() 正在返回 null 以用于在返回 jsx 时创建的 Primereact 手风琴中的 div。 I was able to access the div returned by the primereact accordion in previous version of primereact 3.4.0.我能够在之前版本的 primereact 3.4.0 中访问由 primereact 手风琴返回的 div。 React version is same in both cases that is 16.8.3两种情况下的 React 版本相同,即 16.8.3

I would like to know how do I access the div returned from primereact accordion using document.getElementById() in componentDidMount.我想知道如何使用 componentDidMount 中的 document.getElementById() 访问从 primereact 手风琴返回的 div。

PrimeReact 8.3.0 reuires React 17 or greater and you are using 16.8.3. PrimeReact 8.3.0 需要 Reuis 17 或更高版本,而您使用的是 16.8.3。

See: https://primefaces.org/primereact/setup/参见: https://primefaces.org/primereact/setup/

Please note that react >= 17.0.0 and react-dom >= 17.0.0请注意 react >= 17.0.0 和 react-dom >= 17.0.0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM