I have a React Native app developed with Expo, and it includes a Map component that renders a Leaflet map inside a WebView (for mobile).
For the web version (Map.web.tsx
), I’m trying to use react-leaflet
, but I run into the following error when browsing the app:
Static Rendering Error (Node.js)
window is not defined
I discovered that disabling static rendering in app.json resolves the issue:
{
"expo": {
...
"web": {
"bundler": "metro",
"output": "single" // changing "static" to "single"
}
}
}
However, I don’t want to disable static rendering for my entire app, but only for the /map route.
My question:
Is there a way to selectively disable static rendering for a specific route in Expo Web? Or do I have to give it up for all routes?
Any guidance or workarounds would be greatly appreciated