Skip to content

Second-level function not doing reactive update #14755

Closed as not planned
Closed as not planned
@hykilpikonna

Description

@hykilpikonna

Describe the bug

Second-level function updates are not triggering reactive update, as it's not wrapped with $.mutate by the compiler. Is there a way to manually do $.mutate?

<script lang="ts">
  let obj = {count: 0}	
  const increment = () => obj.count++
	const helper = (o) => o.count++
</script>

<div>count is {obj.count}</div>

<button onclick={increment}>+1</button>
<button onclick={() => helper(obj)}>+1</button>

image

Reproduction

https://svelte.dev/playground/19fcb36153b84f83b83fb9ba92b38463?version=5.14.4

Logs

No response

System Info

System:
    OS: Windows 11 10.0.22631
    CPU: (16) x64 AMD Ryzen 7 7840HS with Radeon 780M Graphics
    Memory: 3.75 GB / 27.69 GB
  Binaries:
    Node: 22.5.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.22 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 10.8.2 - C:\Program Files\nodejs\npm.CMD
    bun: 1.1.38 - ~\.bun\bin\bun.EXE
  Browsers:
    Edge: Chromium (127.0.2651.74)
    Internet Explorer: 11.0.22621.3527

Severity

annoyance

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