Home >Web Front-end >Front-end Q&A >What should I do if react cannot obtain page elements?
React cannot obtain page elements because the hidden tabpane does not render DOM by default. The solution is: 1. Open the corresponding react file; 2. Find the forceRender code part; 3. Set forceRender to "true" That’s it.
The operating environment of this tutorial: Windows 10 system, react18.0.0 version, Dell G3 computer.
What should I do if react cannot get the page elements?
The elements in the tabs hidden page cannot be obtained in react antd useEffect
Specific problem description:
The page has multiple tabs tabs, in the second Echarts is used in the tab page, and the div used to render Echarts is defined and the id is set, but the dom element cannot be obtained in useEffect
(If it is not obtained in useEffect, the same error will be reported)
render:
useEffect:
TypeError:
Error report
Cause:
Hidden tabpane does not render dom by default
Solution:
Set forceRender to true
## Recommended learning: "react video tutorial"
The above is the detailed content of What should I do if react cannot obtain page elements?. For more information, please follow other related articles on the PHP Chinese website!