# Components

There are 2 kind of components: **Stateless** components that we saw in the Hello World sample and **Stateful** components that maintains a state.

To create a stateful  component in ReactorUI just derive from RxComponent\<T> where T is a class that defines the state of the component.

Let's change the Hello World project adding a component that implement a counter page. Replace the code in the MainComponent.cs file with the following (you can edit the file on the fly and hot reload the page):

```csharp
public class MainComponentState : IState
{
    public int Counter { get; set; }
}

public class MainComponent : RxComponent<MainComponentState>
{
    public override VisualNode Render()
    {
        return new RxNavigationPage()
        {
            new RxContentPage()
            {
                new RxStackLayout()
                {
                    new RxLabel($"You clicked {State.Counter} times!")
                        .FontSize(Xamarin.Forms.NamedSize.Large),
                    new RxButton("Click Here!")
                        .OnClick(OnButtonClicked)
                }
                .VCenter()
                .HCenter()
            }
            .Title("Hello World")
        };
    }

    private void OnButtonClicked()
    {
        SetState(s => s.Counter++);
    }
}
```

&#x20;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://adospace.gitbook.io/reactorui/guide/components-with-a-state.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
