schiehll / react-alert

alerts for React
MIT License
608 stars 98 forks source link

TypeError: Failed to execute 'removeChild' on 'Node': parameter 1 is not of type 'Node'. #81

Closed rj-david closed 6 years ago

rj-david commented 6 years ago

4.0.3 fixed the issue of setState() being called on an unmounted component. Now I'm getting this new error:

TypeError: Failed to execute 'removeChild' on 'Node': parameter 1 is not of type 'Node'.
    at Provider.componentWillUnmount (http://localhost:3002/packages/modules.js?hash=f9dfe780ebac6970830f8af0cc9ff39c4d63e2eb:46162:21)
    at callComponentWillUnmountWithTimer (http://localhost:3002/packages/modules.js?hash=f9dfe780ebac6970830f8af0cc9ff39c4d63e2eb:14050:14)
    at HTMLUnknownElement.callCallback (http://localhost:3002/packages/modules.js?hash=f9dfe780ebac6970830f8af0cc9ff39c4d63e2eb:4447:14)
    at Object.invokeGuardedCallbackDev (http://localhost:3002/packages/modules.js?hash=f9dfe780ebac6970830f8af0cc9ff39c4d63e2eb:4485:16)
    at invokeGuardedCallback (http://localhost:3002/packages/modules.js?hash=f9dfe780ebac6970830f8af0cc9ff39c4d63e2eb:4534:29)
    at safelyCallComponentWillUnmount (http://localhost:3002/packages/modules.js?hash=f9dfe780ebac6970830f8af0cc9ff39c4d63e2eb:14057:7)
    at commitUnmount (http://localhost:3002/packages/modules.js?hash=f9dfe780ebac6970830f8af0cc9ff39c4d63e2eb:14303:13)
    at unmountHostComponents (http://localhost:3002/packages/modules.js?hash=f9dfe780ebac6970830f8af0cc9ff39c4d63e2eb:14646:9)
    at commitDeletion (http://localhost:3002/packages/modules.js?hash=f9dfe780ebac6970830f8af0cc9ff39c4d63e2eb:14676:5)
    at commitAllHostEffects (http://localhost:3002/packages/modules.js?hash=f9dfe780ebac6970830f8af0cc9ff39c4d63e2eb:15760:13)

It was this line: document.body.removeChild(this.state.root)

We might need to add a check regarding this.state.root

schiehll commented 6 years ago

I could not reproduce the error, but makes sense to check for if before trying to remove it in this case, so I published a new version.

v4.0.4 should fix it.