Skip to content

Commit

Permalink
Fix debug crash (#4507)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoviDeCroock authored Sep 24, 2024
1 parent 24d06dc commit abca0dc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion debug/src/debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,9 @@ export function serializeVNode(vnode) {

options._hydrationMismatch = (newVNode, excessDomChildren) => {
const { type } = newVNode;
const availableTypes = excessDomChildren.map(child => child.localName);
const availableTypes = excessDomChildren
.map(child => child && child.localName)
.filter(Boolean);
console.error(
`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)}`
);
Expand Down
5 changes: 4 additions & 1 deletion src/internal.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ declare global {
errorInfo?: ErrorInfo | undefined
): void;
/** Attach a hook that fires when hydration can't find a proper DOM-node to match with */
_hydrationMismatch?(vnode: VNode, excessDomChildren: PreactElement[]): void;
_hydrationMismatch?(
vnode: VNode,
excessDomChildren: Array<PreactElement | null>
): void;
}

export type ComponentChild =
Expand Down

0 comments on commit abca0dc

Please sign in to comment.