Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

useLeafletContext() can only be used in a descendant of <MapContainer> #1

Closed
creimers opened this issue Jul 29, 2021 · 2 comments
Closed

Comments

@creimers
Copy link

Hi,

I'm trying to use the VectorTileLayer component with react-leaflet and nextjs 11. I haven't been able to work around this error though:

Unhandled Runtime Error

Error: No context provided: useLeafletContext() can only be used in a descendant of <MapContainer>
Call Stack
useLeafletContext
node_modules/@react-leaflet/core/esm/context.js (9:0)
useLayer
node_modules/@react-leaflet/core/esm/layer.js (19:37)
LeafComponent
node_modules/@react-leaflet/core/esm/component.js (41:5)
renderWithHooks
node_modules/react-dom/cjs/react-dom.development.js (14985:0)
updateForwardRef
node_modules/react-dom/cjs/react-dom.development.js (17044:0)
beginWork
node_modules/react-dom/cjs/react-dom.development.js (19098:0)
...

Any idea why this might be occuring? I literally just copied from your example and replaced the access token with mine...

Thanks!

@ted-piotrowski
Copy link
Owner

@creimers This appears to be a server side rendering error. Can you confirm? If yes, then it appears a limitation of React Leaflet which does not do server side rendering.

Some workarounds may be found here: PaulLeCam/react-leaflet#45

@ted-piotrowski
Copy link
Owner

@creimers which version of React Leaflet are you using?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants