We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c841b73 commit 21bfde6Copy full SHA for 21bfde6
src/Components/Samples/BlazorUnitedApp/Pages/Counter.razor
@@ -4,15 +4,26 @@
4
5
<h1>Counter</h1>
6
7
-<p role="status">Current count: @currentCount</p>
+<p role="status">Current count: @CurrentCount!.Count</p>
8
9
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
10
11
@code {
12
- private int currentCount = 0;
+
13
+ [SupplyParameterFromPersistentComponentState] public CounterState? CurrentCount { get; set; }
14
15
+ protected override void OnInitialized()
16
+ {
17
+ CurrentCount ??= new CounterState();
18
+ }
19
20
private void IncrementCount()
21
{
- currentCount++;
22
+ CurrentCount!.Count = CurrentCount.Count + 1;
23
24
25
+ public class CounterState
26
27
+ public int Count { get; set; } = 0;
28
}
29
0 commit comments