Home >Web Front-end >Front-end Q&A >What should I do if react cannot obtain page elements?

What should I do if react cannot obtain page elements?

藏色散人
藏色散人Original
2023-01-04 09:47:412271browse

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.

What should I do if react cannot obtain page elements?

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:

What should I do if react cannot obtain page elements?

useEffect:

What should I do if react cannot obtain page elements?

TypeError:

What should I do if react cannot obtain page elements?

Error report

Cause:

Hidden tabpane does not render dom by default

What should I do if react cannot obtain page elements?

Solution:

Set forceRender to true

What should I do if react cannot obtain page elements?

## 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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn