hyperapp: {...props} causes TypeError
This code crashes due to children
being assigned to the <div>
. I think it works in React. I’m assuming React doesn’t pass children
when it’s empty. Not sure though.
TypeError: Attempted to assign to readonly property.
TypeError: undefined is not an object (evaluating 'e.childNodes')
Broken Code
export default ({...props}) =>
<div {...props}>Example!</div>
Working Code
export default ({children, ...props}) =>
<div {...props}>Example!</div>
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 22 (10 by maintainers)
In Inferno & Preact,
children
gets stripped from theprops
object.Another interesting thing when passing children to props was that you can use such thing
instead of the link inside the Foo tag
Kinda like the first one and found it useful.
I’d go with option 1. Especially since you’re not shipping hyperx anymore, and instead welcoming any plugin-renderers, they nearly all expect children to be its own parameter.
@dodekeract
Component functions only receive a single
data
(props) argument, why then:I think I’ll need an example I can actually run in order to figure this out.