alexmingoia / purescript-pux

Build type-safe web apps with PureScript.
https://www.purescript-pux.org
Other
566 stars 76 forks source link

Single element children props is not an array with preact #132

Open jmatsushita opened 7 years ago

jmatsushita commented 7 years ago

Hi there,

I've reproduced the problem I alluded to in #131 about differences between preact and react.

Basically it seems that when passing a children array in preact it is passed as a VNode with children whereas in React it is passed as an array of objects.

I'm shortly pushing two forks of the todomvc example that I used to reproduce the problem. They use a simple React component wrapper that replaces the ul element that holds the todo items and logs the children prop to the console.

In preact the console shows: image

While in react: image

This causes some problems interoperating with React components that expect an Array here. At first it seemed related to module aliasing but in the end I don't think it is.

Any thoughts if this is a pux problem or an upstream problem?

Jun

jmatsushita commented 7 years ago

Oh, it seems that the children is not an array when it is a single element. i.e. when passed a two element children then both branches work the same.

jmatsushita commented 7 years ago

I've added a failing travis test in this fork's pull request