@@ -49,7 +49,7 @@ export function render(vnode, parentDom, replaceNode) {
 			: null;
 
 	if (isHydrating) {
-		replaceNode = excessDomChildren[0];
+		replaceNode = excessDomChildren ? excessDomChildren[0] : null;
 	}
 
 	let commitQueue = [];
import { EMPTY_OBJ, EMPTY_ARR } from './constants';
import { commitRoot } from './diff/index';
import { createElement, Fragment } from './create-element';
import options from './options';
import { mount } from './diff/mount';
import { patch } from './diff/patch';

const IS_HYDRATE = EMPTY_OBJ;

/**
 * Render a Preact virtual node into a DOM element
 * @param {import('./internal').ComponentChild} vnode The virtual node to render
 * @param {import('./internal').PreactElement} parentDom The DOM element to
 * render into
 * @param {import('./internal').PreactElement} [replaceNode] Optional: Attempt to re-use an
 * existing DOM tree rooted at `replaceNode`
 */
export function render(vnode, parentDom, replaceNode) {
	if (options._root) options._root(vnode, parentDom);

	// We abuse the `replaceNode` parameter in `hydrate()` to signal if we
	// are in hydration mode or not by passing `IS_HYDRATE` instead of a
	// DOM element.
	let isHydrating = replaceNode === IS_HYDRATE;

	// To be able to support calling `render()` multiple times on the same
	// DOM node, we need to obtain a reference to the previous tree. We do
	// this by assigning a new `_children` property to DOM nodes which points
	// to the last rendered tree. By default this property is not present, which
	// means that we are mounting a new tree for the first time.
	let oldVNode = isHydrating
		? null
		: (replaceNode && replaceNode._children) || parentDom._children;
	vnode = createElement(Fragment, null, [vnode]);

	// List of effects that need to be called after diffing.
	let newVNode = ((isHydrating
		? parentDom
		: replaceNode || parentDom
	)._children = vnode);

	let excessDomChildren =
		replaceNode && !isHydrating
			? [replaceNode]
			: oldVNode
			? null
			: parentDom.childNodes.length
			? EMPTY_ARR.slice.call(parentDom.childNodes)
			: null;

	if (isHydrating) {
		replaceNode = excessDomChildren[0];
	}

	let commitQueue = [];
	if (oldVNode) {
		patch(
			parentDom,
			// Determine the new vnode tree and store it on the DOM element on
			// our custom `_children` property.
			newVNode,
			oldVNode || EMPTY_OBJ,
			EMPTY_OBJ,
			parentDom.ownerSVGElement !== undefined,
			excessDomChildren,
			commitQueue,
			replaceNode || EMPTY_OBJ
		);
	} else {
		mount(
			parentDom,
			newVNode,
			EMPTY_OBJ,
			parentDom.ownerSVGElement !== undefined,
			excessDomChildren,
			commitQueue,
			replaceNode,
			isHydrating
		);
	}

	// Flush all queued effects
	commitRoot(commitQueue, vnode);
}

/**
 * Update an existing DOM element with data from a Preact virtual node
 * @param {import('./internal').ComponentChild} vnode The virtual node to render
 * @param {import('./internal').PreactElement} parentDom The DOM element to
 * update
 */
export function hydrate(vnode, parentDom) {
	render(vnode, parentDom, IS_HYDRATE);
}

In the above we set `excessDomChildren` to null potentially so we need to check whether or not this is possible else we have to set it to null