paol-imi / react-reparenting

The reparenting tools for React
https://paol-imi.github.io/react-reparenting
MIT License
481 stars 8 forks source link

React error after reparenting #31

Closed toschlog closed 2 years ago

toschlog commented 2 years ago

I recently started using react-reparenting and it was a huge win. Thank you so much.

However, I'm sometimes getting an error in the render after reparenting. I assume I'm doing something bad but I'm not sure what it is. I'm continuing to investigate, but I thought I'd post the error here in case anyone has seen it before and has some useful information.

Uncaught Error: Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue.
    at unmountHostComponents (react-dom.development.js:21259)
    at commitDeletion (react-dom.development.js:21347)
    at commitMutationEffects (react-dom.development.js:23407)
    at HTMLUnknownElement.callCallback (react-dom.development.js:3945)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:3994)
    at invokeGuardedCallback (react-dom.development.js:4056)
    at commitRootImpl (react-dom.development.js:23121)
    at unstable_runWithPriority (scheduler.development.js:468)
    at runWithPriority$1 (react-dom.development.js:11276)
    at commitRoot (react-dom.development.js:22990)
    at performSyncWorkOnRoot (react-dom.development.js:22329)
    at react-dom.development.js:11327
    at unstable_runWithPriority (scheduler.development.js:468)
    at runWithPriority$1 (react-dom.development.js:11276)
    at flushSyncCallbackQueueImpl (react-dom.development.js:11322)
    at flushSyncCallbackQueue (react-dom.development.js:11309)
    at discreteUpdates$1 (react-dom.development.js:22420)
    at discreteUpdates (react-dom.development.js:3756)
    at dispatchDiscreteEvent (react-dom.development.js:5889)

Thanks.

toschlog commented 2 years ago

I've resolved this issue, I think. I was calling the reparent function before the first render, when there were in fact no parents. It didn't crash when I did that, but it seems to have caused the crash down the line.