diff --git a/.changeset/early-parents-raise.md b/.changeset/early-parents-raise.md new file mode 100644 index 00000000..2a94babd --- /dev/null +++ b/.changeset/early-parents-raise.md @@ -0,0 +1,5 @@ +--- +"@prefresh/core": patch +--- + +add guard for undefined component before accessing parentDom diff --git a/packages/core/src/index.js b/packages/core/src/index.js index ca481c85..6c80ef4e 100644 --- a/packages/core/src/index.js +++ b/packages/core/src/index.js @@ -54,7 +54,7 @@ function replaceComponent(OldType, NewType, resetHookState) { pendingUpdates = pendingUpdates.filter(p => p[0] !== OldType); vnodes.forEach(vnode => { - if (!vnode.__c.__P) return; + if (!vnode.__c || !vnode.__c.__P) return; // update the type in-place to reference the new component vnode.type = NewType;