Comments (7)
@tunnckoCore Right. I overlooked it also works with raw h
calls.
This is evident from the fact JSX is translated into h
calls when using babel.
from hyperapp.
@jbucaran This feature only works for JSX.
Why not to work for raw h calls? It would, since h
can accept first argument to be function as what tags with uppercased first later is transformed/transpiled to. Nothing needed.
const tree = <Foo name="Charlike" title="Hello">Hello World</Foo>
// => h(Foo, { name: 'Charlike', title: 'Hello' }, 'Hello World')
if it is <foo ...
instead of <Foo
it will be h('foo' ...)
instead of h(Foo ...)
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.
<foo name="hello">world</foo>
=>h('foo', { name: 'hello' }, 'world')
<Foo name="hello">world</Foo>
=>h(Foo, { name: 'hello' }, 'world')
from hyperapp.
Yea just seen the slider. It looks great!
when using babel.
Or rollup-plugin-jsx
from hyperapp.
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')
from hyperapp.
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 <p />
may look kinda strange, but I believe it would work. Another way is as usual
<p>{children}</p>
Because children
is just a Node. Maybe. For that virtual dom i'm not sure if all that will work. But in mich-h it works that way and looks fantastic, kinda love it :)
from hyperapp.
@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 <MyComponent propts=...>children</MyComponent>
.
@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 h
functions hasn't been merged either:
Maybe @substack's is busy? 👋
If we can get that merged, we might be able to propose further changes, like <MyComponent></MyComponent>
-style via Hyperx, which would be sweet.
from hyperapp.
@rbiggs I think we can close now. Function composition is supported in HyperApp via h
. As a result, it just works with JSX, but not with Hyperx, unfortunately, and there's nothing actionable we can do here.
It doesn't look like it will be supported any time soon, see:
from hyperapp.
Related Issues (20)
- A way to insert raw Html HOT 1
- TypeError: can't access property 0, newSubs is null, when setting the state to undefined. HOT 4
- Issue with null-vnodes HOT 1
- prevent rerender node HOT 2
- The dispatch initializer ends in an endless loop on init when dispatching any action HOT 7
- Injected classes gets removed when using object/array to define class props HOT 1
- hyperapp version HOT 3
- Memo Data Gotcha HOT 5
- Confusing doc for actions -> wrapped actions HOT 5
- Passing arguments to init HOT 4
- [Question] Headless mode is still possible? HOT 1
- Destroying a child app HOT 8
- @hyperapp/html: use a Proxy? HOT 9
- Actions returning other Actions HOT 5
- Compile template tag to hyperscript HOT 17
- A challenge to hyperapp community HOT 1
- Has 2.0 been dropped from development? HOT 3
- oldSub[2] is not a function HOT 3
- Cannot read properties of null (reading 'length') HOT 5
- Unlikely Use Case bug in HTML and SVG Packages HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hyperapp.