Open JamesForan opened 2 years ago
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.
contextKey
getContext
mapbox.js
mapbox.js file updated from: const contextKey = {} export { contextKey }
const contextKey = {} export { contextKey }
to const contextKey = "contextKey" export { contextKey }
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..
Map.svelte
What is the recommended way to achieve custom components with this library?
I have the same Problem. Did you solve it, @JamesForan ?
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 successfullygetContext
in svelte.in themapbox.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 @beyonkMap.svelte
component. this also worked..What is the recommended way to achieve custom components with this library?