Blazor Components Flashcards
How to write component names?
Should be written in PascalCase.
What syntax does the Blazor components use?
It uses the Razor syntax.
How to create the most simple component as possible?
Just extract the html and place in a .razor file. Then use it in the place you extracted the HTML.
What is the “App” component and on which server deployment schema is it used?
The app component is the root of any blazor app, either WASM or serverside blazor.
How does the Blazor component structure look like?
Components within components within components and so on..
Would an access to the filesystem be equal on blazor wasm and server side blazor?
No… they differ. On server side it would open the server folder.
Are the structure and feature equal on both blazor deploy model?
Yes.
What is the difference between a razor component and a razor page?
Structurally none. The page has the @page instruction indicating the route.
How to create a library containing razor components?
By using a razor class library.
What does the “razor shared lib” template contain?
wwwroot folder, an _imports and an example component.
How to use a library in the project?
Create a reference to the component lib project and adding a @using statement in the _imports.razor
Does visual studio/vscode generate a class for each razor file? What is its extension and what is the base class it inherits?
Yes. Every razor file generates a razor.g.cs that has a class that inherits from ComponentBase.
When moving the code from the razor file to a dedicated c# file, which class do we need to inherit? What needs to be done in the razor file?
ComponentBase. It is necessary to define that the razor file @inherits from the class that inherits from component base.
Is there another way to moving the source code to another file other than inheriting from component base?
Yes. with partial classes.
Where are the default event handlers (such as @onClick) stored?
in the ms.aspnetcore.components.web