Skip to content

purescript-react/purescript-react-basic-dom

This branch is up to date with main.

Folders and files

NameName
Last commit message
Last commit date
Jun 18, 2022
Nov 8, 2024
Nov 8, 2024
Jun 18, 2022
May 24, 2022
Jun 30, 2020
May 24, 2022
Jun 30, 2020
May 24, 2022
Jun 30, 2020
Jun 30, 2020
Jun 30, 2020
Jul 7, 2022
Jul 22, 2022
May 24, 2022
May 24, 2022
Jul 22, 2022
Jul 22, 2022
Jul 22, 2022
Jul 8, 2022
Jun 18, 2022

Repository files navigation

purescript-react-basic-dom

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.