-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed as not planned
Closed as not planned
Copy link
Labels
✔️ Resolution: AnsweredResolved because the question asked by the original author has been answered.Resolved because the question asked by the original author has been answered.Status: Resolvedarea-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor Components
Description
Is there an existing issue for this?
- I have searched the existing issues
Is your feature request related to a problem? Please describe the problem.
When passing an instance of a reference type to a parameter in a blazor component, I can use someling like this:
[Parameter]
[EditorRequired]
public Model Model {get; set;}
This results in a warning that the property Model may be null.
Making the property required makes the warning go away. (Making it "init" prevents my code from accidentally updating the property).
[Parameter]
[EditorRequired]
public required Model Model {get; init;}
This seems to work and does everything I want. As far as I can tell, this behavior is not publically documenten, so I am not certain it will keep working in future versions of Blazor.
Describe the solution you'd like
Provide information in the documentation about the use of required and init for parameter and inject properties.
Additional context
No response
Metadata
Metadata
Assignees
Labels
✔️ Resolution: AnsweredResolved because the question asked by the original author has been answered.Resolved because the question asked by the original author has been answered.Status: Resolvedarea-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor Components