Skip to content

Reactivity update twice when bind array or object on a component. #4265

Closed
@RyanK1m

Description

@RyanK1m

Describe the bug
I'm trying to use double bind to retrieve values from a component.
Bind simple value like integer, float, string works just fine. When the value inside of the component changes, a parent gets reactivity update from component only once.
But if I want to bind an array or object, I got two updates from values changes inside of the component.

Logs
NA

To Reproduce
REPL:
https://svelte.dev/repl/b0204a06a3f24ede8850017c8b20b998?version=3.17.1

  1. Press Test1 button
  2. updateCount1 should increase +1 but increases +2
  3. Press Test2 button
  4. updateCount1 should increase +1 and it increases +1

Expected behavior
Double bind should cause reactivity update only once.

Stacktraces
NA

Information about your Svelte project:

  • Your browser and the version: Chrome Version 79.0.3945.117 (Official Build) (64-bit)

  • Your operating system: OS X 10.14.6

  • Svelte version 3.17.1

  • Rollup

Severity
This could potentially cause problems for users who want to track more complex objects from their components.

Additional context
I'm trying to build a multi-value-selectable select component.
https://svelte.dev/repl/4ddae394dcf841a687c76f6a9e702c8e?version=3.17.1
But I get reactivity update twice, and this can cause additional network usage if I want to hook value change(In this cause list of selected values) with an API

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions