New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use function for composition #82
Comments
Nope, it isn't only JSX. You could do const { h } = require('hyperapp')
function Foo ({ name, title, children }) {
return h('section', [
h('h1.heading', title + ' ' + name),
h('p', children)
])
}
const tree = h(Foo, { name: 'Charlike', title: 'Hello' }, 'Hello World') |
and JSX variant, i believe /** @jsx h */
const { h } = require('hyperapp')
const Foo = ({ name, title, children }) => (<section>
<h1 className="heading">{title} {name}</h1>
<p children={children} />
</section>)
const tree = <Foo name="Charlike" title="Hello">Hello World</Foo> That
Because |
@rbiggs This feature only works for JSX. I'll update the docs to add an example. In Hyperx you can do like @ungoldman's suggests in choojs/hyperx#9), but that's not nearly as convenient as @niksy's fork of hyperxify seems to deal with this via Hyperx, but it hasn't been merged yet. Our fork of hyperxify to support custom Maybe @substack's is busy? 👋 If we can get that merged, we might be able to propose further changes, like |
Why not to work for raw h calls? It would, since const tree = <Foo name="Charlike" title="Hello">Hello World</Foo>
// => h(Foo, { name: 'Charlike', title: 'Hello' }, 'Hello World') if it is edit: just to be clear if some ELI5 comes haha :) I just learned it yesterday, it got me few hours to understand what happens when is uppercased first letter and why my virtual dom fails, haha.
|
@tunnckoCore Right. I overlooked it also works with raw This is evident from the fact JSX is translated into |
Yea just seen the slider. It looks great!
Or |
@rbiggs I think we can close now. Function composition is supported in HyperApp via It doesn't look like it will be supported any time soon, see: |
In the checkin #77 you mention about returning a function for composition. This is not mentioned in the README. An example would be nice to illustrate how this works. Is this a feature that only works with JSX? Is so, could it also be implemented to work with Hyperx?
The text was updated successfully, but these errors were encountered: