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

Canvas infinite loop issue (Svelte 3/4) #158

Open
techniq opened this issue May 16, 2024 · 1 comment
Open

Canvas infinite loop issue (Svelte 3/4) #158

techniq opened this issue May 16, 2024 · 1 comment

Comments

@techniq
Copy link
Owner

techniq commented May 16, 2024

Creating this issue mostly to document, as this workaround has been used in the docs for a while.


There is a known Svelte 3/4 reactivity issue with $: as documented by LayerCake (see issue)

image

It also sounds like this is fixed in Svelte 5

For Svelte 3/4 (and until LayerCake updates to Svelte 5 / runes), the workaround is to use separate <Canvas> instances, for example:

<Chart geo={...}>
  <Canvas>
    <GeoPath geojson={states} class="stroke-surface-content" />
  </Canvas>

  <Canvas>
    <GeoPath geojson={counties} class="stroke-surface-content/20" />
  </Canvas>
</Chart>
@mhkeller
Copy link

It will be interesting to see what the best Svelte 5 pattern is for this.

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