Skip to content

Conversation

@chris-schneider-zen
Copy link
Contributor

@chris-schneider-zen chris-schneider-zen commented Aug 27, 2025

Description

As of React v19 defaultProps is fully deprecated. Currently in React v18 it does warn against this being removed, so we can easily migrate these within the codebase.

This PR does the work of eliminating and replace defaultProps with one of two patterns:
a. default parameter values (with destructuring)
b. nullish coalescing within styled::attrs() callbacks

Details

@@ -21,9 +21,9 @@ const AccordionComponent = forwardRef<HTMLDivElement, IAccordionProps>(
       children,
       isBare,
       isCompact,
-      isAnimated,
+      isAnimated = true,
       isExpandable,
-      isCollapsible,
+      isCollapsible = true,
       level,
       onChange,
       defaultExpandedSections,
@@ -103,11 +103,6 @@ const AccordionComponent = forwardRef<HTMLDivElement, IAccordionProps>(
 
 AccordionComponent.displayName = 'Accordion';
 
-AccordionComponent.defaultProps = {
-  isAnimated: true,
-  isCollapsible: true
-};
-

Checklist

  • 👌 design updates will be Garden Designer approved (add the designer as a reviewer)
  • 🌐 demo is up-to-date (npm start)
  • ⬅️ renders as expected with reversed (RTL) direction
  • ⚫ renders as expected in dark mode
  • 🤘 renders as expected with Bedrock CSS (?bedrock)
  • 💂‍♂️ includes new unit tests. Maintain existing coverage (always >= 96%)
  • ♿ tested for WCAG 2.1 AA accessibility compliance
  • 📝 tested in Chrome, Firefox, Safari, and Edge

Copy link
Member

@jzempel jzempel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic 💪 thanks so much. And thanks for addressing the review comments from #2008. We'll leave this for @ze-flo to review and then get it merged next week in time for Thursday's release.

@jzempel jzempel changed the title Replace defaultProps with function default parameters fix: replace defaultProps with function default parameters Sep 4, 2025
Copy link
Contributor

@ze-flo ze-flo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice and thorough work! 🔥 💯 🚀


StyledStatusIndicatorBase.defaultProps = {
theme: DEFAULT_THEME,
$size: 'small'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$size is always defined in consuming component. 💯

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch during review! I completely forgot to explicitly call that out in my description 🙇🏼

@jzempel jzempel merged commit 8aeaca9 into main Sep 4, 2025
10 checks passed
@jzempel jzempel deleted the chris.schneider/2025-08-27/migrate-default-props branch September 4, 2025 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants