preactjs / preactjs/preact-render-to-string
`preact/debug` warnings not thrown because `vnode.__k` is not set
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 727
- Forks
- 101
- Avg merge
- 3d 6h
- Merged PRs (30d)
- 6
Description
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>)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked invalid-children branch in debug/src/debug.js and reproduce the issue with the renderToString example from the report. Trace the server-rendering path for vnode.__k and verify the invalid-child check is reached; done means the shown object child causes renderToString to throw the documented error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- backend, web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100