Skip to content

$state array does not update on page back when reassigned #15038

Closed
@0XPW87

Description

@0XPW87

Describe the bug

When using the page back browser button, an array declared with $state is not reactive when using reassignment to change its value in firefox

Reproduction

let favourites = $state([])

onMount(() => {
     //this is a network promise in the actual code
     Promise.resolve({"favourites": [1, 2, 3]}).then(res => {


           //-----this causes the state to not update
           favourites = res["favourites"];
           //----


           //===but when using this, it works
           favourites.length = 0;
           for(let a of res["favourites"]){
                 favourites.push(a);
           }
           //====


     })
})

System Info

Observed only in firefox (my version - Mozilla Firefox 128.5.0esr)- not in chromium, AND only when "Disable cache" in network dev tools is turned off

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    awaiting submitterneeds a reproduction, or clarification

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy