Search code examples
c#blazorblazor-state-management

Blazor State Management - Factor out the state preservation to a common location


enter image description here

I'm trying to understand common location for state preservation from Blazor Official Doc.

  • Should wrapping code be defined in separate razor component?
  • How that component would refer currentCount variable?

enter image description here

I have tried to define this into new component like above in my project, but variable is undefined.

How Counter.razor and CounterStateProvider.razor will be associated together?

enter image description here


Solution

  • To summarize comments to help some on in future.

    CurrentCount is the property in defined in above class.