DEV Community

loading...

Discussion on: Blazor Components: How to Split Template and C# Code

Collapse
edcharbeneau profile image
Ed Charbeneau #Blazor #StateHasChanged

We no longer need to inherit from ComponentBase. This was the pattern when code-behind was done through inheritance. With partial classes ComponentBase should be available from the other part(ial).

However, it's likely you'll still need the using statement for proper scope and more importantly the [Inject] attribute.
using Microsoft.AspNetCore.Components;

Collapse
claudiobernasconi profile image
Claudio Bernasconi Author

Thank you very much for pointing that out, Ed. I was not aware of this change. I don't think it hurts to define it the way I do it above, but it's great to see that it is not required anymore.