Created
August 21, 2022 17:31
-
-
Save pete-murphy/852f261fb3aefbf9f41d17c6a2ef4af8 to your computer and use it in GitHub Desktop.
Render unicode in React text element
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 HelloReactHooks.Main where | |
import Prelude | |
import Data.Maybe (Maybe(..)) | |
import Effect (Effect) | |
import Effect.Exception (throw) | |
import React.Basic.DOM as R | |
import React.Basic.DOM.Client (createRoot, renderRoot) | |
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 root." | |
Just container -> do | |
reactRoot <- createRoot container | |
renderRoot reactRoot (R.text "I will display \x2190") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment