Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

getContext for custom svelte map component #67

Open
JamesForan opened this issue Apr 11, 2022 · 1 comment
Open

getContext for custom svelte map component #67

JamesForan opened this issue Apr 11, 2022 · 1 comment

Comments

@JamesForan
Copy link

JamesForan commented Apr 11, 2022

I am currently experimenting with using svelte-mapbox in my project.

As part of this, I have built a custom 'mapLine.svelte' component.

I am trying to getContext in the following way:

import { contextKey } from '@beyonk/svelte-mapbox/src/lib/mapbox' const { getMap } = getContext(contextKey);

This is not working as expected though. For this to work, I have to set contextKey to a "string" for it to successfully getContext in svelte.in the mapbox.js file I am importing.

mapbox.js file updated from:
const contextKey = {} export { contextKey }

to
const contextKey = "contextKey" export { contextKey }

Keen to understand the correct way to do this.

The other thing I tried was to set the contextKey in my project, and pass this in as a parameter to @beyonk Map.svelte component. this also worked..

What is the recommended way to achieve custom components with this library?

@hburrichter
Copy link

I have the same Problem. Did you solve it, @JamesForan ?

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

No branches or pull requests

2 participants