Code Monkey home page Code Monkey logo

Comments (7)

jorgebucaran avatar jorgebucaran commented on April 27, 2024 2

@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.

tunnckoCore avatar tunnckoCore commented on April 27, 2024 1

@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.

tunnckoCore avatar tunnckoCore commented on April 27, 2024 1

Yea just seen the slider. It looks great!

when using babel.

Or rollup-plugin-jsx

from hyperapp.

tunnckoCore avatar tunnckoCore commented on April 27, 2024

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.

tunnckoCore avatar tunnckoCore commented on April 27, 2024

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.

jorgebucaran avatar jorgebucaran commented on April 27, 2024

@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.

jorgebucaran avatar jorgebucaran commented on April 27, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.