Zaid-Ajaj / Feliz

A fresh retake of the React API in Fable and a collection of high-quality components to build React applications in F#, optimized for happiness
https://zaid-ajaj.github.io/Feliz/
MIT License
540 stars 78 forks source link

Multiple elements child to root #621

Closed reinux closed 2 weeks ago

reinux commented 3 weeks ago

Sorry I'm probably missing something obvious here, but is there a way to have multiple child elements to the root where the program is injected?

For example:

let view model dispatch =
  [  div [ Html.text "something" ]
    div [ Html.text "something else" ]
  ]

This naturally causes a type error, since it's expecting a ReactElement as opposed to a ReactElement list.

The reason I ask is that Bulma may or may not misbehave unless its elements are the direct child of <body>.

Zaid-Ajaj commented 3 weeks ago

Hi @reinux you can use React.fragment [ ... ] for this:

let view model dispatch = React.fragment [
  div [ Html.text "something" ]
  div [ Html.text "something else" ]
]
reinux commented 2 weeks ago

Ah, no wonder I couldn't find it. It's under React. Thanks!