File tree Expand file tree Collapse file tree 4 files changed +26
-22
lines changed Expand file tree Collapse file tree 4 files changed +26
-22
lines changed Original file line number Diff line number Diff line change 22 "license" : " MIT" ,
33 "devDependencies" : {
44 "esbuild" : " ^0.14.49" ,
5- "parcel" : " ^2.6.0 " ,
5+ "parcel" : " ^2.6.2 " ,
66 "process" : " ^0.11.10" ,
7- "purescript" : " ^0.15.3 " ,
8- "spago" : " ^0.20.3 "
7+ "purescript" : " ^0.15.4 " ,
8+ "spago" : " ^0.20.9 "
99 },
1010 "dependencies" : {
11- "ace-builds" : " ^1.4.11 " ,
12- "big-integer" : " ^1.6.48 " ,
13- "react" : " ^16.14 .0" ,
14- "react-dom" : " ^16.14 .0" ,
15- "xhr2" : " ^0.2.0 "
11+ "ace-builds" : " ^1.7.1 " ,
12+ "big-integer" : " ^1.6.51 " ,
13+ "react" : " ^18.2 .0" ,
14+ "react-dom" : " ^18.2 .0" ,
15+ "xhr2" : " ^0.2.1 "
1616 }
1717}
Original file line number Diff line number Diff line change 11let upstream =
2- https:// github. com/ purescript/ package- sets/ releases/ download/ psc- 0.15 . 3 - 20220712 / packages. dhall
3- sha256: ffc496e19c93f211b990f52e63e8c16f31273d4369dbae37c7cf6ea852d4442f
2+ https:// github. com/ purescript/ package- sets/ releases/ download/ psc- 0.15 . 4 - 20220723 / packages. dhall
3+ sha256: efb50561d50d0bebe01f8e5ab21cda51662cca0f5548392bafc3216953a0ed88
44
55let overrides = {= }
66
Original file line number Diff line number Diff line change 77 , " react-basic-dom"
88 , " react-basic-hooks"
99 , " web-html"
10+ , " web-dom"
1011 ]
1112, packages = ../../ packages. dhall
1213, sources = [ " recipes/HelloReactHooks/src/**/*.purs" ]
Original file line number Diff line number Diff line change 11module HelloReactHooks.Main where
22
33import Prelude
4+
45import Data.Maybe (Maybe (..))
56import Effect (Effect )
67import Effect.Exception (throw )
7- import React.Basic.DOM (render )
88import React.Basic.DOM as R
9+ import React.Basic.DOM.Client (createRoot , renderRoot )
910import React.Basic.Hooks (Component , component )
11+ import Web.DOM.NonElementParentNode (getElementById )
1012import Web.HTML (window )
11- import Web.HTML.HTMLDocument (body )
12- import Web.HTML.HTMLElement (toElement )
13+ import Web.HTML.HTMLDocument (toNonElementParentNode )
1314import Web.HTML.Window (document )
1415
1516main :: Effect Unit
1617main = do
17- body <- body =<< document =<< window
18- case body of
19- Nothing -> throw " Could not find body."
20- Just b -> do
21- helloComponent <- mkHelloComponent
22- render (helloComponent {}) (toElement b)
18+ doc <- document =<< window
19+ root <- getElementById " root" $ toNonElementParentNode doc
20+ case root of
21+ Nothing -> throw " Could not find root."
22+ Just container -> do
23+ reactRoot <- createRoot container
24+ app <- mkApp
25+ renderRoot reactRoot (app {})
2326
24- mkHelloComponent :: Component { }
25- mkHelloComponent = do
26- component " HelloComponent " \_ -> React .do
27+ mkApp :: Component { }
28+ mkApp = do
29+ component " App " \_ -> React .do
2730 pure (R .text " Hello!" )
You can’t perform that action at this time.
0 commit comments