Description
On current master, RescriptReactRouter.useUrl()
crashes.
The actual crash is in the first line of RescriptReactRouter.hash()
:
function hash() {
let window = typeof window === "undefined" ? undefined : window;
if (window === undefined) {
return "";
}
let raw = window.location.hash;
switch (raw) {
case "" :
case "#" :
return "";
default:
return Js_string.sliceToEnd(1, raw);
}
}
The error I get in the browser is
ReferenceError: Cannot access 'window2' before initialization
On the ReScript side we have
switch %external(window) {
...
AFAIK %external
is used to guard the access of window
with typeof
so that the code won't crash if run on a platform that doesn't have window
.
Before #6831 the first line of the JS output was
var $$window = typeof window === "undefined" ? undefined : window;
so the problem did not occur.
/cc @cometkim @cristianoc
Metadata
Metadata
Assignees
Labels
No labels