Skip to content

Instantly share code, notes, and snippets.

@maciejsmolinski
Last active May 29, 2020 22:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maciejsmolinski/2033fcde9c3085b87372181420f34771 to your computer and use it in GitHub Desktop.
Save maciejsmolinski/2033fcde9c3085b87372181420f34771 to your computer and use it in GitHub Desktop.
React demo with PureScript <≡> Can be tested at https://try.purescript.org/?gist=2033fcde9c3085b87372181420f34771
module Main where
import Prelude
import Effect (Effect)
import Data.Maybe (Maybe(..))
import React (ReactElement)
import React.DOM (text)
import ReactDOM (render)
import Web.HTML (window)
import Web.HTML.Window (document)
import Web.HTML.HTMLDocument (body)
import Web.HTML.HTMLElement (toElement)
hello :: ReactElement
hello = text "React in PureScript"
main :: Effect Unit
main = do
body <- map toElement <$> (window >>= document >>= body)
case body of
Nothing -> pure unit
Just el -> render hello el *> pure unit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment