What is the difference between a [Parameter] and a [CascadingParameter], and when is it better to use a cascading value over parameter drilling?
Last updated
A
[Parameter]is set explicitly by the direct parent and only reaches its immediate child. It is easy to trace.A
[CascadingParameter]flows implicitly to any descendant of aCascadingValue, matched by type orName(ideal for themes, auth state,EditContext).Prefer cascading when many nested components need the value and intermediate layers shouldn't relay it (prop drilling). It is less explicit and can cause broader re-renders.
- https://learn.microsoft.com/en-us/aspnet/core/blazor/components/cascading-values-and-parameters?view=aspnetcore-10.0
- https://www.youtube.com/watch?v=jBbTJujQNvo
- https://www.youtube.com/watch?v=o9fQ1cLvNlo
- https://medium.com/@quentinsims89/blazor-component-communication-mastering-parameters-and-cascading-parameters-6ac093023956
- https://www.reddit.com/r/Blazor/comments/1auilwi/component_parameter_and_cascading_parameter_why/
- https://blazor-university.com/components/cascading-values/