ziex/test/data/component/caching.zig
Nurul Huda (Apon) 33ec71739d
refactor(ast): use direct import of zx
- This is to allow importing zx with any other decl name than zx
2026-02-09 11:14:05 +06:00

38 lines
1004 B
Zig

pub fn Page(allocator: zx.Allocator) zx.Component {
var _zx = @import("zx").allocInit(allocator);
return _zx.ele(
.main,
.{
.allocator = allocator,
.children = &.{
_zx.cmp(
Button,
.{ .caching = comptime .tag("10s:button") },
.{ .title = "Custom Button" },
),
_zx.cmp(
Button,
.{ .caching = comptime .tag("10s") },
.{ .title = "Custom Button" },
),
},
},
);
}
const ButtonProps = struct { title: []const u8 };
pub fn Button(allocator: zx.Allocator, props: ButtonProps) zx.Component {
var _zx = @import("zx").allocInit(allocator);
return _zx.ele(
.button,
.{
.allocator = allocator,
.children = &.{
_zx.expr(props.title),
},
},
);
}
const zx = @import("zx");