design-system icon indicating copy to clipboard operation
design-system copied to clipboard

Address "Warning: Support for defaultProps will be removed from function components"

Open night-jellyfish opened this issue 1 year ago • 1 comments

Describe the bug

Our application SCOUT uses version 12.0.0 of the design system and React version 18.3.1. When I run our tests, I see the following warning repeated for many components in the design system:

Warning: Spinner: Support for defaultProps will be removed from function components in a future major release. Use JavaScript default parameters instead.
    at Spinner (scout/client/node_modules/@cmsgov/design-system/dist/react-components/esm/Spinner/Spinner.js:12:73)

Looking at the design system repo, it looks like defaultProps is still in use. I'm wondering if this is something that is being looked at for a future version.

(We also have our own code in SCOUT using defaultProps that needs to be updated).

To Reproduce

Steps to reproduce the behavior:

  1. Start an application like SCOUT that has version 12.0.0 of the design system and React version 18.3.1.
  2. Run the tests locally
  3. Alternatively, you can see a run in Jenkins
  4. Scroll through to see the warnings in the logs

Screenshots

Can be provided in Slack.

Expected behavior

I expect to not see the warning.

Additional context

  • It looks like it started happening after a React update: https://cmsgov.slack.com/archives/CHH0381RD/p1721313796902659
  • The reasons we'd like to fix this are:
    • The amount of noise it creates in our logs makes it difficult to scan the logs for other issues
    • It could block us from updating React

night-jellyfish avatar Mar 19 '25 00:03 night-jellyfish

Thank you for raising this issue @night-jellyfish! We are in the process of upgrading to React 18.3.1 ourselves and hopefully when that happens we'll be able to address this issue directly. Thanks!

jack-ryan-nava-pbc avatar Mar 19 '25 00:03 jack-ryan-nava-pbc

@night-jellyfish this should be addressed in this release. Are you ok with me closing this ticket?

jack-ryan-nava-pbc avatar Sep 26 '25 16:09 jack-ryan-nava-pbc

Yes, thank you for fixing it and following up!

night-jellyfish avatar Sep 26 '25 23:09 night-jellyfish