DavidVollmers / Ignis

The Blazor framework for building modern web applications.
https://ignis.dvolper.dev
MIT License
137 stars 8 forks source link

Method must have a return type #47

Closed NathanVG closed 3 months ago

NathanVG commented 4 months ago

Hi,

I'm trying to make a simple toggle to show or hide a sub menu, however when trying to do it like in the Ignis docs I get this error:

image

I don't really get what I'm doing wrong, when I add void I get a different errors:

image

I'm using .net8

DavidVollmers commented 4 months ago

The ReactiveValue should be initialized in the constructor of your component. In the docs this component is named ReactiveCounter. In your case it is named how you named the file of your component.

A constructor in C# has no return type. But since the name (ReactiveShowSubMenu) is not the name of your component, the compiler thinks you are trying to define a method, which always requires a return type.

I will add a comment to the example to make clear to initialize the reactive value in the constructor of the component!

NathanVG commented 4 months ago

Thank you for clarifying, like you said it wasn't immediately clear from the docs that it was a constructor for the page, which is a bit confusing if you're not used to OOP. I think clarifying this in the docs is a great idea.

DavidVollmers commented 3 months ago

So I updated the documentation to have a comment added in the code: image