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 2
2
"license" : " MIT" ,
3
3
"devDependencies" : {
4
4
"esbuild" : " ^0.14.49" ,
5
- "parcel" : " ^2.6.0 " ,
5
+ "parcel" : " ^2.6.2 " ,
6
6
"process" : " ^0.11.10" ,
7
- "purescript" : " ^0.15.3 " ,
8
- "spago" : " ^0.20.3 "
7
+ "purescript" : " ^0.15.4 " ,
8
+ "spago" : " ^0.20.9 "
9
9
},
10
10
"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 "
16
16
}
17
17
}
Original file line number Diff line number Diff line change 1
1
let 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
4
4
5
5
let overrides = {= }
6
6
Original file line number Diff line number Diff line change 7
7
, " react-basic-dom"
8
8
, " react-basic-hooks"
9
9
, " web-html"
10
+ , " web-dom"
10
11
]
11
12
, packages = ../../ packages. dhall
12
13
, sources = [ " recipes/HelloReactHooks/src/**/*.purs" ]
Original file line number Diff line number Diff line change 1
1
module HelloReactHooks.Main where
2
2
3
3
import Prelude
4
+
4
5
import Data.Maybe (Maybe (..))
5
6
import Effect (Effect )
6
7
import Effect.Exception (throw )
7
- import React.Basic.DOM (render )
8
8
import React.Basic.DOM as R
9
+ import React.Basic.DOM.Client (createRoot , renderRoot )
9
10
import React.Basic.Hooks (Component , component )
11
+ import Web.DOM.NonElementParentNode (getElementById )
10
12
import Web.HTML (window )
11
- import Web.HTML.HTMLDocument (body )
12
- import Web.HTML.HTMLElement (toElement )
13
+ import Web.HTML.HTMLDocument (toNonElementParentNode )
13
14
import Web.HTML.Window (document )
14
15
15
16
main :: Effect Unit
16
17
main = 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 {})
23
26
24
- mkHelloComponent :: Component { }
25
- mkHelloComponent = do
26
- component " HelloComponent " \_ -> React .do
27
+ mkApp :: Component { }
28
+ mkApp = do
29
+ component " App " \_ -> React .do
27
30
pure (R .text " Hello!" )
You can’t perform that action at this time.
0 commit comments