-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Replace defaultProps
with destructuring in function components
#7145
Conversation
Replace `defaultProps` with destructuring in function componentsBuild artifact links for this commit: documentation | landing | table | demoThis is an automated comment from the deploy-preview CircleCI job. |
Revert defaultProps changes to DateInput3 to fix testsBuild artifact links for this commit: documentation | landing | table | demoThis is an automated comment from the deploy-preview CircleCI job. |
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.
Thanks! Scrolled through and I believe we've properly copied the defaults over. Only question is around whether we should share default values through an export somehow.
@@ -146,7 +146,7 @@ export class Dialog extends AbstractPureComponent<DialogProps> { | |||
<div | |||
className={classNames(Classes.DIALOG, className)} | |||
role={role} | |||
aria-modal={overlayProps.enforceFocus ?? Overlay2.defaultProps?.enforceFocus} |
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.
Would it be useful to have Overlay2
still export its default props if we need to reference them internally?
// Overlay2.tsx
export const OVERLAY2_DEFAULT_PROPS = {
enforceFocus: true
};
I think that makes it easier to see the intent of the code here. Otherwise it's more difficult to know why someone chose to default aria-modal
to true
.
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.
Yep, can do! I 👍 had considered something like this originally, but wavered at the time of implementing. I think this is a good idea for posterity since these can technically be consumed externally. Having the export set of values to point to will give us a migration path in case there are any other consumers we are unaware of.
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.
@@ -660,7 +660,7 @@ describe("<DateInput>", () => { | |||
focusInput(wrapper); | |||
changeInput(wrapper, "4/77/2016"); | |||
blurInput(wrapper); | |||
assert.strictEqual(wrapper.find(InputGroup).prop("value"), DateInput.defaultProps?.invalidDateMessage); | |||
assert.strictEqual(wrapper.find(InputGroup).prop("value"), "Invalid date"); |
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.
Similar comment around potentially exporting default props from DateInput
.
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.
// TODO: Removing `defaultProps` here breaks tests. Investigate why. | ||
// eslint-disable-next-line deprecation/deprecation |
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.
That's fun. 😂
Thanks for leaving a comment so others have context on this in the future.
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.
Yeah.. 🥲
I am working on updating/refactoring a lot of the datetime2 tests currently, so will hopefully uncover the cause of this during the process.
Leverage inferred type for backdropProps to fix type errorBuild artifact links for this commit: documentation | landing | table | demoThis is an automated comment from the deploy-preview CircleCI job. |
This test passes locally but fails in CI. Need to investigate why this occurs. ``` Chrome Headless 124.0.6367.201 (Linux x86_64) <Popover> focus management when shouldReturnFocusOnClose={true} moves focus to overlay when opened FAILED Error: Uncaught focus should be inside overlay: expected null to not equal null ... ```
Revert default assignments in Overlay2 props to avoid test flake in CIBuild artifact links for this commit: documentation | landing | table | demoThis is an automated comment from the deploy-preview CircleCI job. |
Invalidated by push of aefacb1
Revert change to replace Popover default props reference in SuggestBuild artifact links for this commit: documentation | landing | table | demoThis is an automated comment from the deploy-preview CircleCI job. |
Copied from React 18 Upgrade feature branch #7142
Proposed changes:
Replaces
defaultProps
with destructuring in anticipation of lint errors that will be encountered in React 18.3.0.Fixes lint errors such as the following:
See also: