Skip to content

Commit dd82808

Browse files
committed
When navigating from post page to post page, the Razor Page object didn't change, but the url parameters did. Moved logic from OnInitialized() to OnParametersSet() because the parameters changed but the page didn't initialize again.
1 parent dcfd948 commit dd82808

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/ProgrammerAl.Site/ProgrammerAl.Site/Pages/Post.razor.cs

+7-3
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,24 @@ public partial class Post : ComponentBase
1919
private MarkupString PostHtml { get; set; }
2020
private PostData? PostData { get; set; }
2121

22-
protected override async Task OnInitializedAsync()
22+
protected override async Task OnParametersSetAsync()
2323
{
24+
PostData = null;
25+
PostHtml = new MarkupString(string.Empty);
26+
2427
if (!string.IsNullOrWhiteSpace(PostUrl))
2528
{
2629
PostData = await PostDataProvider.GetPostAsync(PostUrl);
2730

2831
if (PostData is object)
2932
{
3033
PostHtml = new MarkupString(PostData.PostHtml);
31-
await InvokeAsync(StateHasChanged);
3234
}
3335
}
3436

35-
await base.OnInitializedAsync();
37+
await InvokeAsync(StateHasChanged);
38+
39+
await base.OnParametersSetAsync();
3640
}
3741

3842
private bool ShouldPostRequestFeedback()

0 commit comments

Comments
 (0)