最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Is it possible to use react leaflet in expo web static rendering? - Stack Overflow

programmeradmin2浏览0评论

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

发布评论

评论列表(0)

  1. 暂无评论