Skip to content

Reactivity lost in derived that returns state created outside of derived under certain circumstances #15180

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
Leonidaz opened this issue Feb 1, 2025 · 2 comments · Fixed by #15255

Comments

@Leonidaz
Copy link

Leonidaz commented Feb 1, 2025

Describe the bug

Derived's reactivity seems to be lost if it returns a state created outside of the derived. This happens only if the derived's returned state is mutated in the component instance block (inside <script>).

Reproduction

Reproduction playground

Steps to replicate:

  • click on increment linked button
  • click on increment count button
  • click on increment linked button
  • the reactivity is lost as linked count should have been incremented

removing linked.current++; on line 14 in the <script></script> fixes it

Logs

n/a

System Info

playground

Severity

annoyance

@paoloricciuti
Copy link
Member

You shouldn't reassign state in deriveds, the fact that you can do it in untrack is irrelevant imho. Let's keep this open because I feel this is some unowned shenanigan

@Leonidaz
Copy link
Author

Leonidaz commented Feb 2, 2025

unowned shenanigan

possibly, not sure if it can fixed without #14784

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

Successfully merging a pull request may close this issue.

2 participants