From b48d22dd62eccccf4c208cec2ac8d96165d2ab04 Mon Sep 17 00:00:00 2001 From: kivvvvv Date: Mon, 12 Aug 2024 14:16:49 +0700 Subject: [PATCH 1/2] fix: component props from attrs not respecting provided transient props --- src/index.test.tsx | 16 ++++++++++++++++ src/index.tsx | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/index.test.tsx b/src/index.test.tsx index 8d82a5c..b102d90 100644 --- a/src/index.test.tsx +++ b/src/index.test.tsx @@ -279,4 +279,20 @@ describe("twc", () => { expect(svg).toBeDefined(); expect(svg.tagName).toBe("SVG"); }); + + test("component props from attrs should respect provided transient props", () => { + type ButtonProps = TwcComponentProps<"button"> & { + variant: "primary" | "secondary"; + }; + const Button = twc.button + .transientProps(["variant"]) + .attrs(({ type = "button", variant }) => { + expect(variant).toBe("primary"); + return { type }; + })`text-xl`; + render(