Skip to content

Instantly share code, notes, and snippets.

@pete-murphy
Created August 21, 2022 17:31
Show Gist options
  • Save pete-murphy/852f261fb3aefbf9f41d17c6a2ef4af8 to your computer and use it in GitHub Desktop.
Save pete-murphy/852f261fb3aefbf9f41d17c6a2ef4af8 to your computer and use it in GitHub Desktop.
Render unicode in React text element
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