Package

purescript-react-basic-dom

Repository
purescript-react/purescript-react-basic-dom
License
Apache-2.0
Uploaded by
pacchettibotti
Published on
2024-11-08T16:57:33Z

Build Status React Basic DOM on Pursuit

This library contains the React Basic DOM modules.

Example

import Prelude

import Data.Maybe (Maybe(..))
import Effect (Effect)
import Effect.Exception (throw)
import React.Basic.DOM.Client (createRoot, renderRoot)
import React.Basic.DOM (text)
import Web.DOM.NonElementParentNode (getElementById)
import Web.HTML (window)
import Web.HTML.HTMLDocument (toNonElementParentNode)
import Web.HTML.Window (document)

main :: Effect Unit
main = do
  doc <- document =<< window
  root <- getElementById "root" $ toNonElementParentNode doc
  case root of
    Nothing -> throw "Could not find container element"
    Just container -> do
      reactRoot <- createRoot container
      renderRoot reactRoot (text "Hello")

More examples can be found in the PureScript Cookbook.