Created
February 8, 2020 17:21
-
-
Save jjl/c0dd87e07a33b14ff1b656895ac94206 to your computer and use it in GitHub Desktop.
This file contains 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 (main) where | |
import Prelude (Unit, ($), pure, unit) | |
import Data.Maybe (Maybe(..)) | |
import Data.Nullable (toMaybe) | |
import DOM.Simple (Element) | |
import DOM.Simple.Document (document) | |
import DOM.Simple.Console (log) | |
import Effect (Effect) | |
import FFI.Simple ((...), args2, delay) | |
import Reactix as R | |
import Reactix.DOM.HTML as H | |
main :: Effect Unit | |
main = paint $ toMaybe (document ... "getElementById" $ [ "app" ]) | |
paint :: Maybe Element -> Effect Unit | |
paint Nothing = log "[main] Container not found" | |
paint (Just c) = render (app {}) c | |
render :: R.Element -> Element -> Effect Unit | |
render e d = delay unit $ \_ -> pure $ R.reactDOM ... "render" $ args2 e d | |
app :: {} -> R.Element | |
app props = R.createElement appCpt props [] | |
appCpt :: R.Component () | |
appCpt = R.hooksComponent "HelloJohnny" cpt where | |
cpt _ _ = pure (H.div {} [H.text "Hello Johnny"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment