Skip to content

Commit 21bfde6

Browse files
committed
tmp
1 parent c841b73 commit 21bfde6

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/Components/Samples/BlazorUnitedApp/Pages/Counter.razor

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,26 @@
44

55
<h1>Counter</h1>
66

7-
<p role="status">Current count: @currentCount</p>
7+
<p role="status">Current count: @CurrentCount!.Count</p>
88

99
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
1010

1111
@code {
12-
private int currentCount = 0;
12+
13+
[SupplyParameterFromPersistentComponentState] public CounterState? CurrentCount { get; set; }
14+
15+
protected override void OnInitialized()
16+
{
17+
CurrentCount ??= new CounterState();
18+
}
1319

1420
private void IncrementCount()
1521
{
16-
currentCount++;
22+
CurrentCount!.Count = CurrentCount.Count + 1;
23+
}
24+
25+
public class CounterState
26+
{
27+
public int Count { get; set; } = 0;
1728
}
1829
}

0 commit comments

Comments
 (0)