-
Notifications
You must be signed in to change notification settings - Fork 61
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
React LabelGroup linking fix #271
Conversation
@@ -16,13 +16,17 @@ class LabelGroup extends BaseComponent <LabelGroupArgs, any> { | |||
if (Array.isArray(this.props.children) || !this.props.children) { | |||
throw new Error('A LabelGroup must contain a single child react component'); | |||
} | |||
const labelFieldChild = (this.props.children as { type: any, props: any }); |
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.
Not straightforward to provide types here?
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.
I've updated the types and included an explanation.
I've updated this PR to include fixes for #270. Re-requesting a review. |
throw new Error(childrenErrorMessage); | ||
} | ||
// casting child as a single ReactElement as we have confirmed it is above | ||
const child = this.props.children as ReactElement; |
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.
Why is the name of the property children
if it's a single child? Looks a bit odd.
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 children prop is provided by react and includes any child react elements a user has added to their LabelGroup. It's then been limited to a single react element above this line.
React LabelGroup fields were not being linked to an observer when a link property was passed in. Updates to PCUI components wrapped in a LabelGroup should now correctly update their bound observer.