Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default function renderToElement(
renderer: DOMRenderer,
mountNode: DOMNode
): Function {
// mountNode must be a valid HTML element to be able
// to set mountNode.textContent later on
if (!isValidHTMLElement(mountNode)) {
throw new Error(
'You need to specify a valid element node (mountNode.nodeType = 1) to render into.'
)
}
return renderer.subscribe(() => {
mountNode.textContent = renderToString(renderer)
})
}