Open mateusvahl opened 8 months ago
If you are using Shopify customer accounts, you can fix it by:
self.window = {};
self.document= {
createElement = () => { /** empty **/ };
}
(Remember that window
is not accessible in Shopify customer account/webworker, so we "simulate" its presence).
-
It seems that there's very few places in the source code that uses window
, we could probably fix it by using self
What version of React Router are you using?
6.22.2
Steps to Reproduce
I'm running
react-router-dom
in Shopify customer account ui environmentThis runs on a webworker with a subset javascript API and no access to DOM APIs.
When using
useFetcher()
, thesubmit
action was throwing an error saying:After further investigation in the source code, I notice it was related to to isBrowser detection, which expects
window.document.createElement !== "undefined"
(false in my environment).A workaround was define createElement before initialise the route, which fixes the detection.
Let me me know if any additional details is needed.
Expected Behavior
isBrowser
should not really onwindow.document.createElement
Actual Behavior
window.document.createElement
is undefined, leadingisBrowser
to be considered false.