Home > Software design >  How to avoid warning 8618 in razor control when using CascadingParameter?
How to avoid warning 8618 in razor control when using CascadingParameter?

Time:08-24

I receive a cascading parameter inside a razor control. This is the Authentificaction State.

[CascadingParameter]
private Task<AuthenticationState> authenticationStateTask { get; set; } 

But this line raise a warning (CS8618)

Non-nullable property 'authenticationStateTask ' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Since this is a Taks, the null forgiving operator (!) doesn't work.

How I can avoid this warnign?

In enter image description here

After: enter image description here

  • Related