Last active
May 29, 2020 22:45
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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