Hyperapp: undefined element

Created on 2 May 2018  路  9Comments  路  Source: jorgebucaran/hyperapp

After rendering a pretty simple app the result is

<body>
<div id="root"><undefined></undefined></div>
</body>

There are no errors in the console.
I am new to hyperapp, so it seems pretty likely I missed something. If this does turn out to be something simple I would still expect there to be an error in the console.

Inquiry

Most helpful comment

@infinnie ...will they be in version 2.0?

Later.

But will arrays ever be supported as values returned by top-level components?

Yes, eventually. I want to add proper document fragment at some point, but it's not a pressing priority at the moment.


About the specific case of returning arrays from the top-level view: remember that unlike e.g., React/Preact, a Hyperapp app consists of a single top-level view/component always.

All 9 comments

It is not supported for top-level components to return arrays.

See #362.

@tyrsius Your application requires a root element; you can't return an array from the top level view.

To correct your example you may do:

const App = ({ orders }) => {
  return h("main", { class: "root" }, orders.map(order => h(OrderItem, { order })))
}

I would still expect there to be an error in the console.

This is a reasonable feature request. Currently I am not offering a "dev" build for Hyperapp, but it has been proposed before and I would be happy to discuss how we could offer one.

But will arrays ever be supported as values returned by top-level components? Or will they be in version 2.0?

@jorgebucaran @infinnie oh man, these docs on the front page sure make it seem like you can

@tyrsius Components can be arrays, but views can't. In your example, App is the view so it can't be an array.

@infinnie ...will they be in version 2.0?

Later.

But will arrays ever be supported as values returned by top-level components?

Yes, eventually. I want to add proper document fragment at some point, but it's not a pressing priority at the moment.


About the specific case of returning arrays from the top-level view: remember that unlike e.g., React/Preact, a Hyperapp app consists of a single top-level view/component always.

@jorgebucaran Thank you for explaining the difference 馃槃

I do still think logging an error in this case is a good idea. Outputting <undefined></undefined> with no error doesn't make debugging very... possible.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dmitrykurmanov picture dmitrykurmanov  路  4Comments

guy-kdm picture guy-kdm  路  4Comments

ghost picture ghost  路  3Comments

zhaotoday picture zhaotoday  路  3Comments

jorgebucaran picture jorgebucaran  路  3Comments