Hyperapp: Hyperapp throws "length of undefined" when the child component returns an array

Created on 18 Oct 2017  路  5Comments  路  Source: jorgebucaran/hyperapp

I have a Parent component that takes a bunch of children elements and simply returns them. Hyperapp throws length of undefined in the createElement function.

Codepen: https://codepen.io/rajaraodv/pen/VMqBNB
Note:

  1. This only happens if the main Parent component is not itself wrapped in something but is the main/direct element for the view function.
  2. If I wrap the children array in {children} then the resulting DOM shows <undefined>...children elements... </undefined>

Expected: It should render the children elements.

const { h, app } = hyperapp;
/** @jsx h */

const Parent = ({ state, actions }, children) => {
  return children; //<-- returning w/o "{" "}" causes error in Hyperapp
};
app({
  state: {
    count: 0
  },
  view: (state, actions) => (
    <Parent state={state} actions={actions}>
      <h1>raja</h1>
      <h2> rao</h2>
    </Parent>
  )
});

screen shot 2017-10-18 at 3 54 26 am

Most helpful comment

This only happens if the main Parent component is not itself wrapped in something but is the main/direct element for the view function.

This is a known limitation of hyperapp. Components may return arrays, but view specifically may not

All 5 comments

This only happens if the main Parent component is not itself wrapped in something but is the main/direct element for the view function.

This is a known limitation of hyperapp. Components may return arrays, but view specifically may not

362

@rajaraodv I still don't understand what you expect Hyperapp to do here.

362 will not be implemented, so perhaps you were not aware? So, maybe move this to #417?

<undefined></undefined> is weird though; maybe we should make this issue about only that oddity.

Thoughts?

Yeah, probably moving this to #417 is a good idea since there is nothing Hyperapp can do other than warn people.

417

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dmitrykurmanov picture dmitrykurmanov  路  3Comments

jacobtipp picture jacobtipp  路  3Comments

guy-kdm picture guy-kdm  路  4Comments

ghost picture ghost  路  3Comments

Mytrill picture Mytrill  路  4Comments