- 
                Notifications
    You must be signed in to change notification settings 
- Fork 19
Open
Description
Proposing that we add a renderInRoot helper function to make this common pattern easier:
import React.Basic.DOM.Util (renderInRoot)
myComponent :: Component {}
myComponent = do
  component "MyComponentName" \_ -> React.do
    -- ...
main :: Effect Unit 
main = renderInRoot $ myComponent {}A slightly more verbose option is:
import React.Basic.DOM.Util (createRootElement)
mkMyComponent :: Component {}
mkMyComponent = do
  component "MyComponentName" \_ -> React.do
    -- ...
main :: Effect Unit 
main = do
  root <- createRootElement
  myComponent <- mkMyComponent
  render (myComponent {}) rootWe could support both options, and reuse createRootElement in renderInRoot.
For context, Halogen has some convenient helper functions for launching components, such as awaitBody in Halogen.Aff.Util:
hookComponent = Hooks.component \_ _ -> Hooks.do
  -- ...
main :: Effect Unit
main =
  HA.runHalogenAff do
    body <- HA.awaitBody
    void $ runUI hookComponent Nothing bodyMetadata
Metadata
Assignees
Labels
No labels