Skip to content

Commit abca0dc

Browse files
authored
Fix debug crash (#4507)
1 parent 24d06dc commit abca0dc

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

debug/src/debug.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,9 @@ export function serializeVNode(vnode) {
585585

586586
options._hydrationMismatch = (newVNode, excessDomChildren) => {
587587
const { type } = newVNode;
588-
const availableTypes = excessDomChildren.map(child => child.localName);
588+
const availableTypes = excessDomChildren
589+
.map(child => child && child.localName)
590+
.filter(Boolean);
589591
console.error(
590592
`Expected a DOM node of type ${type} but found ${availableTypes.join(', ')}as available DOM-node(s), this is caused by the SSR'd HTML containing different DOM-nodes compared to the hydrated one.\n\n${getOwnerStack(newVNode)}`
591593
);

src/internal.d.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ declare global {
4646
errorInfo?: ErrorInfo | undefined
4747
): void;
4848
/** Attach a hook that fires when hydration can't find a proper DOM-node to match with */
49-
_hydrationMismatch?(vnode: VNode, excessDomChildren: PreactElement[]): void;
49+
_hydrationMismatch?(
50+
vnode: VNode,
51+
excessDomChildren: Array<PreactElement | null>
52+
): void;
5053
}
5154

5255
export type ComponentChild =

0 commit comments

Comments
 (0)