Previous tip (Use Error Boundaries to localise errors)
Next tip (NavLink gives you more useful navigation links) >>
Set multiple parameters in one go with Attribute Splatting
Sometimes you don’t want (or need) to handle every parameter explicitly.
You can use a Dictionary
to capture any arbitrary attributes someone might try to set on your component, then ‘splat’ those into another component
For example, an ImportantPanel
component which delegates to a Panel
component…
<Panel @attributes="Attributes" EmphasisColor="#FF0004"/>
@code {
[Parameter(CaptureUnmatchedValues = true)] public Dictionary<string, object> Attributes { get; set; }
}