question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
zacenocommented, Oct 18, 2017

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

1reaction
rajaraodvcommented, Oct 19, 2017

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot read property 'length' of undefined when trying to get ...
I am trying to render the number of players from my players JSX to my app but keep getting Cannot read property 'length'...
Read more >
Typeerror: Cannot Read Property 'length' of Undefined
Return the number of elements inside of an array with Array.prototype.length . Find out the number of arguments passed into a function with ......
Read more >
Beginning Functional JavaScript - Springer Link
array elements, right? It looks like we are telling the compiler what to do, however. In this case, we are telling the compiler,...
Read more >
30 seconds of interviews
A curated collection of common web development interview questions to help you prepare for your next interview.
Read more >
angular/angular - Gitter
How can I lazy load the child module in my super application? ... the subscriber's onNext returns an array of the results from...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found