Skip to content

Commit 2dd2152

Browse files
committed
Merge remote-tracking branch 'origin/v4.x' into v5.x
2 parents a685ba8 + 9ab5bdb commit 2dd2152

File tree

7 files changed

+6346
-38383
lines changed

7 files changed

+6346
-38383
lines changed

.github/workflows/ci.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ jobs:
1212
runs-on: ubuntu-latest
1313

1414
steps:
15-
- uses: actions/checkout@v2
15+
- uses: actions/checkout@v4
1616
- name: Setup .NET
17-
uses: actions/setup-dotnet@v1
17+
uses: actions/setup-dotnet@v4
1818
with:
19-
dotnet-version: 6.0.x
19+
dotnet-version: '9.0.x'
2020
- name: Build
2121
run: ./build.fsx

appveyor.yml

-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
image: Visual Studio 2022
22

3-
install:
4-
- ps: Install-Product node 17 x64
5-
63
build_script:
74
- cmd: dotnet fsi build.fsx
85

build.fsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#r "nuget: Fake.Core.Target, 5.23.1"
66
#r "nuget: Fake.Core.ReleaseNotes, 5.23.1"
77
#r "nuget: Fake.Tools.Git, 5.23.1"
8-
8+
#r "nuget: MSBuild.StructuredLogger, 2.2.441"
99

1010
open Fake.Core
1111
open Fake.Core.TargetOperators

global.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sdk": {
3-
"version": "6.0.100",
3+
"version": "9.0.100",
44
"rollForward": "latestMinor"
55
}
66
}

package-lock.json

+6,317-38,321
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
"devDependencies": {
1919
"@babel/preset-react": "^7.16.0",
2020
"bulma": "^0.9.3",
21-
"gatsby-remark-vscode": "^3.3.0",
22-
"gh-pages": "^3.2.3",
21+
"gatsby-remark-vscode": "^3.3.1",
22+
"gh-pages": "^5.0.0",
2323
"nacara-layout-standard": "^1.4.2",
2424
"react": "^17.0.2",
2525
"react-dom": "^17.0.2",

src/react.fs

+22-52
Original file line numberDiff line numberDiff line change
@@ -19,76 +19,46 @@ module Program =
1919
open Browser
2020
open Elmish
2121

22-
// Use the new rendering API in React 18+
23-
let useRootApi = try int ReactBindings.React.version.[ .. 1 ] >= 18 with _ -> false
24-
2522
let withReactBatchedUsing lazyView2With placeholderId (program:Program<_,_,_,_>) =
2623
let setState =
2724
let mutable lastRequest = None
25+
let root = ReactDomClient.createRoot (document.getElementById placeholderId)
2826

29-
if useRootApi then
30-
let root = ReactDomClient.createRoot (document.getElementById placeholderId)
31-
32-
fun model dispatch ->
33-
match lastRequest with
34-
| Some r -> window.cancelAnimationFrame r
35-
| _ -> ()
36-
37-
lastRequest <- Some (window.requestAnimationFrame (fun _ ->
38-
root.render (lazyView2With (fun x y -> obj.ReferenceEquals(x,y)) (Program.view program) model dispatch)))
39-
else
40-
fun model dispatch ->
41-
match lastRequest with
42-
| Some r -> window.cancelAnimationFrame r
43-
| _ -> ()
27+
fun model dispatch ->
28+
match lastRequest with
29+
| Some r -> window.cancelAnimationFrame r
30+
| _ -> ()
4431

45-
lastRequest <- Some (window.requestAnimationFrame (fun _ ->
46-
ReactDom.render(
47-
lazyView2With (fun x y -> obj.ReferenceEquals(x,y)) (Program.view program) model dispatch,
48-
document.getElementById placeholderId
49-
)))
32+
lastRequest <- Some (window.requestAnimationFrame (fun _ ->
33+
root.render (lazyView2With (fun x y -> obj.ReferenceEquals(x,y)) (Program.view program) model dispatch)))
5034

5135
program
5236
|> Program.withSetState setState
5337

5438
let withReactSynchronousUsing lazyView2With placeholderId (program:Elmish.Program<_,_,_,_>) =
5539
let setState =
56-
if useRootApi then
57-
let root = ReactDomClient.createRoot (document.getElementById placeholderId)
40+
let root = ReactDomClient.createRoot (document.getElementById placeholderId)
5841

59-
fun model dispatch ->
60-
root.render (lazyView2With (fun x y -> obj.ReferenceEquals(x,y)) (Program.view program) model dispatch)
61-
else
62-
fun model dispatch ->
63-
ReactDom.render(
64-
lazyView2With (fun x y -> obj.ReferenceEquals(x,y)) (Program.view program) model dispatch,
65-
document.getElementById placeholderId
66-
)
42+
fun model dispatch ->
43+
root.render (lazyView2With (fun x y -> obj.ReferenceEquals(x,y)) (Program.view program) model dispatch)
6744

6845
program
6946
|> Program.withSetState setState
7047

7148
let withReactHydrateUsing lazyView2With placeholderId (program:Elmish.Program<_,_,_,_>) =
7249
let setState =
73-
if useRootApi then
74-
let mutable root = None
75-
76-
fun model dispatch ->
77-
match root with
78-
| None ->
79-
root <-
80-
ReactDomClient.hydrateRoot (
81-
document.getElementById placeholderId,
82-
lazyView2With (fun x y -> obj.ReferenceEquals(x,y)) (Program.view program) model dispatch
83-
) |> Some
84-
| Some root ->
85-
root.render (lazyView2With (fun x y -> obj.ReferenceEquals(x,y)) (Program.view program) model dispatch)
86-
else
87-
fun model dispatch ->
88-
ReactDom.hydrate(
89-
lazyView2With (fun x y -> obj.ReferenceEquals(x,y)) (Program.view program) model dispatch,
90-
document.getElementById placeholderId
91-
)
50+
let mutable root = None
51+
52+
fun model dispatch ->
53+
match root with
54+
| None ->
55+
root <-
56+
ReactDomClient.hydrateRoot (
57+
document.getElementById placeholderId,
58+
lazyView2With (fun x y -> obj.ReferenceEquals(x,y)) (Program.view program) model dispatch
59+
) |> Some
60+
| Some root ->
61+
root.render (lazyView2With (fun x y -> obj.ReferenceEquals(x,y)) (Program.view program) model dispatch)
9262

9363
program
9464
|> Program.withSetState setState

0 commit comments

Comments
 (0)