You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This runs on a webworker with a subset javascript API and no access to DOM APIs.
When using useFetcher() , the submit action was throwing an error saying:
router.fetch() was called during the server render, but it shouldn't be. You are likely calling a useFetcher() method in the body of your component. Try moving it to a useEffect or a callback.
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.
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.The text was updated successfully, but these errors were encountered: