简体   繁体   中英

How can i ReactDOM.render() multiple react elements into a node without them killing each other?

When I use ReactDOM.render() a few times, it kills the other elements in the node. How can I render multiple react elements into a node without them killing each other?

You can't.

A single DOM node can be host to a single React root. Either

  • add new DOM nodes to that parent node to host multiple React roots, or
  • make the single component you mount something where you can add more components in (in eg a <> fragment).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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