How can you share state between a parent component and deeply nested children without using parameters?
Last updated
Wrap the subtree in
<CascadingValue Value="this">(or a state object) and descendants receive it via[CascadingParameter].For mutable state, the cascaded object exposes update methods and the owner calls
StateHasChanged()to re-render. UseNamewhen several cascaded values share a type.If state must reach beyond one subtree (across pages or unrelated components), use a DI state service instead.
- https://medium.com/@quentinsims89/blazor-component-communication-mastering-parameters-and-cascading-parameters-6ac093023956
- https://medium.com/dotnet-new/state-management-in-blazor-applications-0890c20ca3b2
- https://learn.microsoft.com/en-us/aspnet/core/blazor/components/cascading-values-and-parameters?view=aspnetcore-10.0
- https://www.telerik.com/faqs/blazor/what-are-blazor-cascading-parameters
- https://www.youtube.com/watch?v=o9fQ1cLvNlo
- https://www.telerik.com/blogs/blazor-basics-component-parameters-state-management
- https://www.reddit.com/r/Blazor/comments/inptf8/updating_parent_state_from_deeply_nested_child/
- https://www.youtube.com/watch?v=vNAbforFHT0