svelte-mapbox
svelte-mapbox copied to clipboard
getContext for custom svelte map component
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?
I have the same Problem. Did you solve it, @JamesForan ?