preact-render-to-string
preact-render-to-string copied to clipboard
`preact/debug` warnings not thrown because `vnode.__k` is not set
In preact/debug we have a branch for detecting invalid children being passed to a vnode:
vnode._children.forEach(child => {
if (typeof child === 'object' && child && child.type === undefined) {
const keys = Object.keys(child).join(',');
throw new Error(
`Objects are not valid as a child. Encountered an object with the keys {${keys}}.` +
`\n\n${getOwnerStack(vnode)}`
);
}
});
But we never set that property when rendering on the server, so this check is never called.
Steps to reproduce
import "preact/debug";
import { renderToString } from "preact-render-to-string";
// This should throw
renderToString(<div>{{ foo: 123 }}</div>)