Pass variant value to child component #254
Unanswered
javapyscript
asked this question in
Q&A
Replies: 1 comment
-
I used this to solve my issue.
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Apologies if this has been answered elsewhere, but is there a typesafe way to pass variant information to child components?
I am trying to create a Button component using the useRestyle hook. I have this code:
I extracted out the variant, but passed it back to useRestyle as it expects the variant prop in the second parameter. I lose type safety though when I do so.
Eg: Button variant is 'primary' | 'secondary'. restyleFunctions shows the error:
The types of 'propertiesMap.variant' are incompatible between these types.
Type 'boolean | undefined' is not assignable to type 'boolean'.
Type 'undefined' is not assignable to type 'boolean'.ts(2345)
Thank you.
Beta Was this translation helpful? Give feedback.
All reactions