File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 88</a >
99
1010This library contains the [ React Basic] ( https://github.com/lumihq/purescript-react-basic ) DOM modules.
11+
12+ ## Example
13+
14+ ``` purescript
15+ import Prelude
16+
17+ import Data.Maybe (Maybe(..))
18+ import Effect (Effect)
19+ import Effect.Exception (throw)
20+ import React.Basic.DOM.Client (createRoot, renderRoot)
21+ import React.Basic.DOM (text)
22+ import Web.DOM.NonElementParentNode (getElementById)
23+ import Web.HTML (window)
24+ import Web.HTML.HTMLDocument (toNonElementParentNode)
25+ import Web.HTML.Window (document)
26+
27+ main :: Effect Unit
28+ main = do
29+ doc <- document =<< window
30+ root <- getElementById "root" $ toNonElementParentNode doc
31+ case root of
32+ Nothing -> throw "Could not find container element"
33+ Just container -> do
34+ reactRoot <- createRoot container
35+ renderRoot reactRoot (text "Hello")
36+ ```
37+
38+ More examples can be found in the [ PureScript Cookbook] ( https://github.com/JordanMartinez/purescript-cookbook/tree/master/recipes ) .
You can’t perform that action at this time.
0 commit comments