File tree 2 files changed +17
-1
lines changed
2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -279,4 +279,20 @@ describe("twc", () => {
279
279
expect ( svg ) . toBeDefined ( ) ;
280
280
expect ( svg . tagName ) . toBe ( "SVG" ) ;
281
281
} ) ;
282
+
283
+ test ( "component props from attrs should respect provided transient props" , ( ) => {
284
+ type ButtonProps = TwcComponentProps < "button" > & {
285
+ variant : "primary" | "secondary" ;
286
+ } ;
287
+ const Button = twc . button
288
+ . transientProps ( [ "variant" ] )
289
+ . attrs < ButtonProps > ( ( { type = "button" , variant } ) => {
290
+ expect ( variant ) . toBe ( "primary" ) ;
291
+ return { type } ;
292
+ } ) `text-xl` ;
293
+ render ( < Button data-testid = "button" variant = "primary" /> ) ;
294
+
295
+ const renderedButton = screen . getByTestId ( "button" ) ;
296
+ expect ( renderedButton . getAttribute ( "variant" ) ) . toBeNull ( ) ;
297
+ } ) ;
282
298
} ) ;
Original file line number Diff line number Diff line change @@ -171,7 +171,7 @@ export const createTwc = <TCompose extends AbstractCompose = typeof clsx>(
171
171
172
172
if ( attrs === undefined ) {
173
173
template . attrs = ( attrs : Attributes ) => {
174
- return createTemplate ( attrs ) ;
174
+ return createTemplate ( attrs , shouldForwardProp ) ;
175
175
} ;
176
176
}
177
177
You can’t perform that action at this time.
0 commit comments