Skip to content

Commit eee4fbd

Browse files
committed
use history replaceState for shallow replace on create share link
1 parent ac34e4c commit eee4fbd

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/Playground.res

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,7 +1134,6 @@ module ControlPanel = {
11341134
}
11351135
}
11361136

1137-
@val @scope(("window", "location")) external origin: string = "origin"
11381137
@react.component
11391138
let make = (
11401139
~actionIndicatorKey: string,
@@ -1173,8 +1172,8 @@ module ControlPanel = {
11731172

11741173
let querystring = params->Array.map(((key, value)) => key ++ "=" ++ value)->Array.join("&")
11751174

1176-
let url = origin ++ router.route ++ "?" ++ querystring
1177-
Next.Router.replace(router, url)
1175+
let url = router.route ++ "?" ++ querystring
1176+
Webapi.Window.History.replaceState(null, ~url)
11781177
url
11791178
}
11801179

src/bindings/Webapi.res

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ module Window = {
4848
@scope("window") @val external innerWidth: int = "innerWidth"
4949
@scope("window") @val external innerHeight: int = "innerHeight"
5050
@scope("window") @val external scrollY: int = "scrollY"
51+
52+
module History = {
53+
@scope(("window", "history")) @val
54+
external pushState: (nullable<'a>, @as(json`""`) _, ~url: string=?) => unit = "pushState"
55+
@scope(("window", "history")) @val
56+
external replaceState: (nullable<'a>, @as(json`""`) _, ~url: string=?) => unit = "replaceState"
57+
}
5158
}
5259

5360
module Fetch = {

0 commit comments

Comments
 (0)