Skip to content

Svelte 5: Add ability to manually specify dependencies for $effect rune #13207

Closed as not planned
@kyoshino

Description

@kyoshino

Describe the problem

Dependencies are always unclear in Svelte, and Svelte 5 has causes some new infinite loops as mentioned in #13192. See also #12908.

Describe the proposed solution

Just like useEffect in React, I would like to use the optional second argument of the $effect rune to specify dependencies and untrack other states:

$effect(() => {
  // your logic
}, [a, b, c]);

Basically this is a shorthand of:

$effect(() => {
  void a;
  void b;
  void c;
  untrack(() => {
    // your logic
  });
});

(I usually use void to explicitly specify dependencies)

Importance

would make my life easier

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions