Tom Crosman
Tom Crosman

Reputation: 1285

Blazor: @ref usage confuses visual studio. How to ignore?

Whenever I use the @ref syntax in blazor, visual studio gives me a ton of green underlines on my blazor components that use @ref.

Is there a way to disable this warning? Is it resharper maybe?

Example image here: https://i.sstatic.net/EKkdo.jpg

Upvotes: 0

Views: 555

Answers (2)

Surinder Singh
Surinder Singh

Reputation: 1450

you can enable/disable null warnings at project level with these setting in .csproj file

To disable

<PropertyGroup>
    <Nullable>disable</Nullable>
</PropertyGroup>

To enable

<PropertyGroup>
    <Nullable>enable</Nullable>
</PropertyGroup>

Upvotes: 0

Brian Parker
Brian Parker

Reputation: 14553

The cause is your _tableRef is non-nullable. Try adding a ? :


@code {
    ProjectUserJobRolesTable? _tableRef;
}

Before:

enter image description here

After:

enter image description here

Upvotes: 2

Related Questions