React selector not finding component if it is inside nested root container
See original GitHub issueThis is not an issue if it is react 15 , since it is relying on data-reactroot
attribute on the element and const rootEls = [].slice.call(document.querySelectorAll('[data-reactroot]'));
this code will find all nested root containers.
In react 16 the way to identify root container is using object key el._reactRootContainer
and getRootElsReact16(el)
only looking for peers not nested containers.
For e.g. it will work in below structure
<body>
<div/>
// First root container
<div/>
// Second root container (peer of first)
…
</body>
Will not work in below structure (In this case it will find components that is part of first root container , not from second and Third root container)
<body>
<div>
// First root container
<div>
// Second root container (Nested inside First) </div>
<div>
// Not a react container </div>
<div>
// Third root container (Nested inside First) </div>
</div>
</body>
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (3 by maintainers)
Thank you for the example, I’ve reproduced the issue.
Thank you that was quick!!
On Mon, Jan 13, 2020 at 4:37 AM Boris Kirov notifications@github.com wrote: