DavidVollmers/Ignis

Method must have a return type

Closed this issue · 3 comments

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

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!

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.

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