-
Notifications
You must be signed in to change notification settings - Fork 50k
Description
I believe this is a bug and potentially related to #3298, but the specific details are different enough that I wanted to file a separate issue. Feel free to close if it's the same root cause.
I have a repro here: https://jsfiddle.net/7s6mwccu/2/
- ClickMe is a component that runs
causeErroron click causeErrorfirst renders components of type A and B (let's call them A0 and B0)- B0 has a componentDidMount function that calls setState (comes into play later)
causeErrorthen updates A0 with a new prop- A.componentDidUpdate unmounts B0 and mounts a new B, B1
- After
causeErroris all done, React's runtime performs some ops (presumably due to B0's setState) that leads to:
Warning: React can't find the root component node for data-reactid value
.2. If you're seeing this message, it probably means that you've loaded two copies of React on the page. At this time, only a single copy of React can be loaded at a time.
Uncaught TypeError: Cannot read property 'firstChild' of undefined
Peeking at the stacktrace, it looks like didPutListener is trying to findDOMNode on an already-unmounted component.
Some weird details:
- Leaving off onClick removes this error
- Not calling setState in B.componentDidMount also removes this error
So it's a bit different from #3298 because it's not erroring if we only unmount B during a click; it's erroring if we have onClick and setState.
This is on React 0.14 - I tested it briefly on React 15 and got
Invariant Violation: React DOM tree root should always have a node reference.
which presumably is a better formed version of the same error.