-
Notifications
You must be signed in to change notification settings - Fork 4.6k
HStack, VStack: Stop passing invalid props #59416
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
| function useDeprecatedProps( | ||
| props: WordPressComponentProps< FlexProps, 'div' > | ||
| ): WordPressComponentProps< FlexProps, 'div' > { | ||
| ): Omit< typeof props, 'isReversed' > { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This return type was wrong because it wasn't omitting the deprecated isReversed prop, which is specifically being omitted in this hook. It wasn't causing a TS error per se, but it was making it look like useFlex could return another invalid prop (isReversed) in addition to isColumn.
aaronrobertshaw
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
t-hamano
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the quick fix 🙏
I just want to ask you one thing: After this PR is merged, it's safe to use the implementation below, right?
<HStack as={ motion.div }></HStack>
<VStack as={ motion.div }></VStack>
tyxla
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice and straightforward, thanks! 🚀
@t-hamano That's correct 👍 |


Fixes a bug surfaced in #59193
What?
Stops the HStack and VStack components from passing through invalid props when a component is passed to the
asprop.Why?
The
useHStack/useVStackhooks internally used theuseFlexhook to generate props, which included theisColumnprop. This prop is actually used in theFlexcomponent logic and not passed through to the underlying element, but was neither used nor omitted in the HStack/VStack components and thus passed through.This is fine if an intrinsic element (such as "span") is used for the
asprop, since the underlyingViewcomponent (i.e. an Emotion-styled component) will correctly ignore non-intrinsic props. It can become a problem when a non-Emotion custom component is used for theasprop, because React will throw an error about the invalid prop.How?
Omit the
isColumnprop from the return props of theuseHStackhook, which will also remove it from theuseVStackhook.Testing Instructions