pub fn Page(ctx: zx.PageContext) zx.Component {
    return (
        <main @allocator={ctx.arena}>
            <EventForm @rendering={.client} />
        </main>
    );
}

pub fn EventForm(ctx: *zx.ComponentContext) zx.Component {
    const count = ctx.state(i32, 1);
    return (
        <button onclick={ctx.bind(onclick)}>
            Click Me {count}
        </button>
    );
}

fn onclick(e: *zx.server.Event.Stateful) void {
    const c = e.state(i32);
    c.set(c.get() + 1);
    zx.log.info("Count> {d}. \n", .{c.get()});
}

pub const options: zx.PageOptions = .{
    .methods = &.{ .GET, .POST },
};

const zx = @import("zx");
