Closed maartenbreddels closed 8 months ago
To make this work in solara, use:
import solara # this changes reacton.core. _default_container
import reacton.core
# now restore it
reacton.core. _default_container = reacton.Fragment
Note, Fragment does not have to be used explicitly.
import reacton
import reacton.ipywidgets as w
@reacton.component
def Children():
# will use fragment implicitly, because we have 2 elements
w.Button(description="1")
w.Button(description="2")
@reacton.component
def Test():
with w.VBox():
Children()
Test()
Similar to React, where children in a Fragment will be 'extended' to a parent list (like children) instead of 'appended'
Example
Since solara overrides the '_default_container', this is mandatory to use with solara (even when just imported). For solara v2 we will probably also start using fragments.