dotnet / dotnet/aspnetcore

Provide a simple opt-out option of preserving statically rendered components during navigation

Open
#56,961 6 comments 0 reactions 0 assignees View on GitHub
area-blazor enhancement feature-blazor-ssr
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 6h
Merged PRs (30d)
290

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Describe the bug

The problem is : when I refresh static page that contains interactive component then interactive component is not refreshed.

I've got an app :
![image](https://github.com/user-attachments/assets/142d4e3d-9edf-4792-8779-0c4cca9ab1cb)
![image](https://github.com/user-attachments/assets/a378b751-cd59-4fc1-a6d4-d1159154e549)
![image](https://github.com/user-attachments/assets/a1bbae13-331f-4fd7-8c09-b9beda4d2ba8)

When I click remove last button and refresh page using such code :
var absoluteUri = this.NavigationManager.ToAbsoluteUri(this.NavigationManager.Uri);
this.NavigationManager.NavigateTo(absoluteUri.AbsolutePath);

Then page is refreshed but interactive component not
![image](https://github.com/user-attachments/assets/c87f263e-3c2c-4a7e-88f5-b491e9b79b2c)

If I provide a @key to my interactive component inside static one
![image](https://github.com/user-attachments/assets/bad11baa-5780-4f04-9027-a57748a506c9)

Then all works as expected and interactive component is recreated and displayed
![image](https://github.com/user-attachments/assets/1700f6c4-5ee8-440c-b045-60494c34193c)

Here is link to repo https://github.com/IevgeniiKunshchykov/InteractivePageUpdateInsideStatic.git

Can someone explain me that behavior? Why is that done in such way? Why interactive component is not reinitialized without @key?

Thank you!

### Expected Behavior

Interactive component is reinitialized inside static one

### Steps To Reproduce

_No response_

### Exceptions (if any)

_No response_

### .NET Version

_No response_

### Anything else?

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.