React B page is a child route of page A, A jumps B, then jumps A from B, loops back and forth a few times, and on page B, you will find that the DOM of page An is also displayed on page B.

react B page is a child route of page A, A jumps B, then jumps A from B, and loops back and forth a few times. On page B, you will find that the DOM of page An is also displayed on page B, and the dom of page B is squeezed to the bottom.

what to do?

when the loop clicks to jump, B jumps A, and the life cycle in A cannot be triggered. Triggered only the first time. Unloading also triggers only when it jumps to another sibling child route

at present, my solution is to determine whether the DOM of page A can be obtained in the componeDidMount of page B, and then hide it directly. But it always feels like this is not a method.

another solution is to set up a page, do transit, and normally trigger the uninstall of page A

would you please let me know how to solve the problem if you know something about react?

Mar.03,2021

do not operate in react dom
react do not operate dom
react do not operate dom

it's no use saying it three times. The
page is nested, indicating that the component is not uninstalled after the path jumps.

Menu