@@ -12,9 +12,11 @@ import Yoga.React.DOM.HTML.Blockquote (blockquote) as H
1212import Node.FS.Aff (writeTextFile)
1313import Effect.Aff (launchAff_)
1414import Node.Encoding (Encoding(UTF8))
15−import React.Basic.Hooks (Component, component, useState)
15+import React.Basic.Hooks (Component, component, useRef, useState)
1616import Data.Tuple.Nested ((/\))
1717import React.Basic.Hooks as React
18+import Data.Nullable (Nullable, null)
19+import Yoga.React.DOM.Attributes (reactRef)
1820import Yoga.React.DOM.Client (createRoot, renderRoot)
1921import Web.HTML (window)
2022import Web.HTML.Window (document)
@@ -50,9 +52,12 @@ mkExample = do
5052
5153mkCounter = component "Counter" \_ -> React.do
5254 count /\ setCount <- useState 0
55+ divRef <- useRef null
5356 pure $ fragment
5457 [ H.button { className: "bg-black px-4 py-2 rounded shadow font-bold text-white", onClick: handler_ $ setCount (_ + 1) } "Count up!"
55− , H.p {} ("You clicked me " ++ H.b {} (show count) ++ " times.")
58+ , H.div { ref: reactRef divRef } [ H.p {} ("You clicked me " ++ H.b {} (show count) ++ " times.") ]
59+ , H.div { ref: reactRef callbackRefExample } []
60+ , H.div { ref: reactRef cleanupRefExample } []
5661 ]
5762
5863mainExample = H.main { className: "w-[80ch] max-w-[80ch] bg-white mx-auto shadow" }
@@ -129,7 +134,7 @@ tableExample = H.table { className: "table" }
129134
130135formExample :: JSX
131136formExample = H.div { className: "myForm" }
132− [ H.form { action: "#" }
137+ [ H.form { action: H.urlAction "#" }
133138 [ H.input { type: "text", placeholder: "Type something", className: "inputField" }
134139 , H.input { type: "submit", value: "Submit", className: "submitBtn" }
135140 ]
@@ -151,4 +156,10 @@ formExample = H.div { className: "myForm" }
151156
152157 ]
153158
159+callbackRefExample :: Nullable Unit -> Effect Unit
160+callbackRefExample _ = pure unit
161+
162+cleanupRefExample :: Unit -> Effect (Effect Unit)
163+cleanupRefExample _ = pure (pure unit)
164+
154165x y = y.a + y.b + y.c