[Bug] Importing Leaflet Removes Dynamic Html Head on Build
See original GitHub issueReporting a bug
I am experiencing a rather weird situation using this genius library (please feel free to point me to the chat if it’s better suited there or even directly to the Leaflet community).
I am generating dynamic html information in the build stage which works absolutely fine however as soon as I import leaflet
which we would like to use in our contact form it removes the head information and we just do not understand why.
Environment
System:
OS: macOS Mojave 10.14.6
CPU: (8) x64 Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
Memory: 736.20 MB / 16.00 GB
Shell: 5.3 - /bin/zsh
Binaries:
Node: 10.17.0 - ~/.nvm/versions/node/v10.17.0/bin/node
Yarn: 1.17.3 - /usr/local/bin/yarn
npm: 6.11.3 - ~/.nvm/versions/node/v10.17.0/bin/npm
Browsers:
Chrome: 80.0.3987.163
Safari: 13.0.4
Steps to Reproduce the problem
- MVP can be found here
git clone https://github.com/TimMcCauley/react-static-leaflet-head-bug.git
yarn install
yarn build && yarn serve
- Check the markup after building with and without line 3 in
react-static-leaflet-head-bug/src/containers/Post.js
- With will strip out the dynamic Head and without react-helmet will build the html perfectly.
Expected Behavior
I would expect that importing leaflet would have no effect on the generation of the html head.
Reproducible Demo
https://github.com/TimMcCauley/react-static-leaflet-head-bug
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
getting error on leaflet dynamic import on Next.js 10 #18336
After updating the project we are working on, we started to get a critical error on dynamic load level of leaflet. The important...
Read more >85 - Stack Overflow
I got this error after upgrade react-leaflet to version 3.2.0 to fix an error while removing markers with permanent tooltips from the map....
Read more >Integrating Next.js with Leaflet.js + Mapbox
Tutorial · Install the required dependencies · Creating the map component · Setting up Mapbox API · Adding a custom TileLayer to React...
Read more >Use Dynamic Components to render HTML for 3rd party libraries
In this example we're going to learn how we can leverage dynamic Angular components to render the HTML of a popup controlled by...
Read more >Plugins - Leaflet - a JavaScript library for interactive maps
The following plugins provide new ways of loading overlay data (GIS vector data): points, lines and polygons. Overlay data formats; Dynamic data loading ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@SleeplessByte you are a star… it finally WORKS, did exactly how you explained and it makes total sense. I updated the code in the repository:
https://github.com/TimMcCauley/react-static-leaflet-head-bug/blob/master/src/containers/Post.js
Cheers a bunch for this stunning hint!
/T
Given that
src/core/Browser.js
is targetting the browser – perhaps what you can try is conditionally import leaflet, for now. So basically, instead of doing:you only import it when in the browser (And not on build):
If that makes it work, at least we know where to look.