State is wiped out when page is refresh in blazor with fluxor

1.3k Views Asked by At

I am not sure how to handle this behavior, this is the Feature I have:

public class HolderFeature : Feature<HolderState>
    {
        public override string GetName() => "HolderState";
        protected override HolderState GetInitialState() => new(holder: new ProductHolder(), persons: string.Empty);        
    }

And, everything works fine until a page is refreshed (pressing f5), the state is wiped out, I have this to handle the error:

 protected override void OnInitialized()
        {
            if (HolderState.Value.QuotedProduct.Quotes != null)
            {
                //do the logic
            }
            else
            {
              //show error screen
                PressedF5 = true;
            }
        }

What I expect is that even when the page is refreshed it shouldn't wipe out the state. how can I do that?

1

There are 1 best solutions below

0
On

The state is stored in memory. When you refresh the page you are unloading it and starting from scratch, so all the memory is lost if it isn't persisted somewhere.