3 ms·
I was skeptical at first, but this is really cool: > In Cycle.js you can omit the props object. Since props are always an object and children are always an arr
by temuze 11y ago
I was skeptical at first, but this is really cool:
> In Cycle.js you can omit the props object. Since props are always an object and children are always an array, it’s obvious which parameter is what:
ul([
li('Foo'),
li('Bar'),
])
That's a lot cleaner than JSX. Kudos.
- bphogan 11y agoYea. That's kinda like what Elm does for its views. ul [] [ li [] text "Foo"], li [] text "Bar"] ] Took a while to "get" it, but now I really like it. (`ul` and `li` are functions that take two lists - the first is a list of attributes like class or ID or whatnot, and the second is the inner content... text or other elements.)
- guidopallemans 11y agoyou forgot some braces: ul [] [ li [] [text "Foo"], li [] [text "Bar"] ]
- bphogan 11y agoHah! I did. Thanks!
- Lazare 11y agoFYI, that's nothing to do with Cycle, that's just hyperscript. Works great with React if you feel the urge: https://github.com/mlmorg/react-hyperscript https://github.com/mlmorg/react-hyperscript The syntax is slightly different though: h('ul', [ h('li', 'Foo'), h('li', 'Bar'), ]) Otherwise the same advantages as the author listed when using Cycle, eg, props and children are both optional, etc.