Pass single node in place of children?
See original GitHub issueRight now this seems illegal:
// works
h('div', {className: 'new-style'}, [node])
// does not work!
h('div', {className: 'new-style'}, node)
because of
export function h(sel: string, children: Array<VNode | undefined | null>): VNode;
(https://github.com/snabbdom/snabbdom/blob/master/src/h.ts#L19)
The latter seems to be cleaner and less cluttered though. Would it be possible to support?
Here is some further motivation with examples:
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
How to update a single child node from a list of ... - GitHub
I have an Explorer Treeview and a parent in the tree can have hundreds of child nodes. Each child node then has right...
Read more >How to initialize a child process with passed in functions in ...
The problem I'm running into is that, when using Child Processes in NodeJS, you can't pass functions to the child process and my...
Read more >How To Launch Child Processes in Node.js - DigitalOcean
With our script in place, we can write a new Node.js module to execute it. This script will use execFile() to run the...
Read more >Node.js Child Processes: Everything you need to know
Single -threaded, non-blocking performance in Node.js works great for a single process. But eventually, one process in one CPU is not going ...
Read more >React Children And Iteration Methods - Smashing Magazine
In this article, we'll discuss and learn about the use case of iterating over React `children` and the ways to do it. In...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@caesarsol You are right, it does work indeed here, lol 😉
It didn’t work with Preact-hyperscript, so I must have mixed things up.
I guess I should perhaps close this issue then.
I’m using snabbdom in JS and the single child syntax works!
Take a look at https://github.com/snabbdom/snabbdom/blob/master/src/h.ts#L32 in which the second and third arguments are checked for presence of
.sel
(to identify a vnode) and assigned to children as single-element array.I’m guessing it’s only forbidden by TS signature.
(Or am I missing something?)