diff --git a/README.md b/README.md index 825aef4..4913f0d 100644 --- a/README.md +++ b/README.md @@ -8,3 +8,31 @@ This library contains the [React Basic](https://github.com/lumihq/purescript-react-basic) DOM modules. + +## Example + +```purescript +import Prelude + +import Data.Maybe (Maybe(..)) +import Effect (Effect) +import Effect.Exception (throw) +import React.Basic.DOM.Client (createRoot, renderRoot) +import React.Basic.DOM (text) +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 container element" + Just container -> do + reactRoot <- createRoot container + renderRoot reactRoot (text "Hello") +``` + +More examples can be found in the [PureScript Cookbook](https://github.com/JordanMartinez/purescript-cookbook/tree/master/recipes). \ No newline at end of file pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy