purescript-contrib / purescript-react

React Bindings for PureScript
MIT License
397 stars 65 forks source link

Smarter `Monoid` instance for `ReactElement` #157

Closed natefaubion closed 1 year ago

natefaubion commented 5 years ago

React still sometimes has trouble with [] as mempty if you are returning it from a render method. We should use null as mempty. Additionally, we should make a smarter append that does not build nested fragments, but instead concatenates Arrays.

thomashoneyman commented 3 years ago

I think we should try and get this in for the upcoming breaking release for PureScript 0.14.

thomashoneyman commented 3 years ago

We may not be able to get this in for 0.14 due to a backlog of other work, so I'm going to remove the label.

JordanMartinez commented 1 year ago

Fixed by #187

natefaubion commented 1 year ago

To be clear, I only changed it so that mempty is null and it avoids creating redundant fragments if one of the elements is also null. There isn't a reliable way of always flattening to an Array in append, and it may not even be desirable. I think the most reliable way if it's something you want is to use reacts Children.toArray API to flatten at the end.