Skip to content

How to correctly use imported classes from other libraries in Svelte 5? #14436

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

Closed
Tb1281 opened this issue Nov 26, 2024 · 1 comment
Closed

Comments

@Tb1281
Copy link

Tb1281 commented Nov 26, 2024

Describe the bug

In Svelte 5, classes are no longer auto-reactive (see migration guide).

I'm trying to use CodeMirror, but I'm running into issues with how to manage the editor instance. For example, the following code seems problematic:

let editor = $state();
$effect.pre(() => {
  editor = new EditorView(...);
  return () => editor?.destroy();
});

The issue arises because the props of the EditorView class are not wrapped in $state(...), which means they're not reactive.

Is there a recommended way to handle this in Svelte 5? How can I ensure that the editor instance and its properties remain reactive in this scenario?

Reproduction

https://svelte.dev/playground/0aca148ac2fc4301b6b5a7605dc57c7d?version=5.2.8

Logs

No response

System Info

All

Severity

annoyance

@brunnerh
Copy link
Member

Duplicate of:

See in particular this comment.

@dummdidumm dummdidumm closed this as not planned Won't fix, can't repro, duplicate, stale Nov 26, 2024
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

3 participants