Skip to content
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

[fix] DatePicker component uses defaultProps which is to be deprecated and causes console warning. #2918

Open
Steven7926 opened this issue May 10, 2024 · 2 comments
Labels
type: bug Something isn't working like it's supposed to

Comments

@Steven7926
Copy link

Steven7926 commented May 10, 2024

ReactUSWDS Version & USWDS Version:

"@trussworks/react-uswds": "^9.0.0",
"@uswds/uswds": "3.7.1",

Describe the bug

When building a form using your component library I kept running into a console waring stating:

"Support for defaultProps will be removed from function components in a future major release. Use JavaScript default parameters instead."

Upon further investigation I found that this was coming from the DatePicker component. At the end of DatePicker.tsx you are using
DatePicker.defaultProps = {
minDate: DEFAULT_MIN_DATE,
}
to set a minimum allowable date for the datepicker component, this is trggering the warning.
defaultProps is also used in the Tooltip component.
To Reproduce
Steps to reproduce the behavior:

  1. Create a page and use the datepicker and tooltip components
  2. Render that page
  3. Open dev tools in the browser and view the console
  4. See error: "Support for defaultProps will be removed from function components in a future major release. Use JavaScript default parameters instead."

Expected behavior

No warning should appear in the console to prep your library for deprecating feature support.

Screenshots

Additional context

Device and Browser Information (please complete the following information if describing a UI bug):
Google Chrome running a Vite React application on Windows.

@aligg
Copy link
Contributor

aligg commented Jun 17, 2024

@Steven7926 and @brandonlenz (saw you've reviewed some things recently) - put up a quick PR for this one in case anyone has cycles to review: #2949

Looks like workflows need approval from a maintainer as well.

@aligg
Copy link
Contributor

aligg commented Jul 18, 2024

A fix for this is now merged and I imagine will go out with the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working like it's supposed to
Projects
None yet
Development

No branches or pull requests

2 participants