Skip to content

Commit a4ebb63

Browse files
authored
Merge pull request #290 from rescript-association/url
Don't wipe playground url on load; update on copy to clipboard
2 parents fcf9661 + bea0365 commit a4ebb63

File tree

2 files changed

+7
-22
lines changed

2 files changed

+7
-22
lines changed

src/Playground.js

Lines changed: 3 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Playground.res

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,7 +1177,7 @@ module ControlPanel = {
11771177
}
11781178
}
11791179

1180-
@bs.val @bs.scope("window.location") external origin: string = "origin"
1180+
@bs.val @bs.scope(("window", "location")) external origin: string = "origin"
11811181
@react.component
11821182
let make = (
11831183
~actionIndicatorKey: string,
@@ -1217,7 +1217,9 @@ module ControlPanel = {
12171217
}
12181218
})
12191219

1220-
origin ++ (router.route ++ querystring)
1220+
let url = origin ++ (router.route ++ querystring)
1221+
Next.Router.replace(router, url)
1222+
url
12211223
}
12221224
<>
12231225
<div className="mr-2">
@@ -1437,19 +1439,6 @@ let default = () => {
14371439
| (None, _) => initialResContent
14381440
}
14391441

1440-
// We cleanup all the unwanted query attributes on load to make
1441-
// sure the url is not getting out of sync with the actual content
1442-
React.useEffect1(() => {
1443-
// Clean out the url after loading all query params
1444-
if router.asPath !== "/try" {
1445-
Next.Router.replace(router, "/try")
1446-
} else {
1447-
()
1448-
}
1449-
1450-
None
1451-
}, [router.route])
1452-
14531442
// We don't count to infinity. This value is only required to trigger
14541443
// rerenders for specific components (ActivityIndicator)
14551444
let (actionCount, setActionCount) = React.useState(_ => 0)

0 commit comments

Comments
 (0)