From bf9f64f771e4c01d6188e661b093d3f94453c875 Mon Sep 17 00:00:00 2001 From: mellamokb Date: Sat, 2 Dec 2023 17:20:46 -0500 Subject: [PATCH] Fix counter value not reloading from AppState. When you open the Counter page, increment, then leave and come back, the counter is reset to 0. However the AppState keeps the increased value. This leads to confusing results when you click the WinForms button because it returns AppState value, which may be different than the page. The fix is to re-load AppState Counter value each time you visit Counter page. --- src/WebviewAppShared/Pages/Counter.razor | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/WebviewAppShared/Pages/Counter.razor b/src/WebviewAppShared/Pages/Counter.razor index 77c0a25..c51ac9c 100644 --- a/src/WebviewAppShared/Pages/Counter.razor +++ b/src/WebviewAppShared/Pages/Counter.razor @@ -10,6 +10,12 @@ @code { private int currentCount = 0; + protected override void OnInitialized() + { + currentCount = AppState.Counter; + base.OnInitialized(); + } + private void IncrementCount() { currentCount++;