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

refactor(React): initialize default props with serially stable values #14720

Merged
merged 31 commits into from
Oct 19, 2023

Conversation

tw15egan
Copy link
Member

@tw15egan tw15egan commented Sep 26, 2023

Closes #10777
Closes #13424

Removes all instances of defaultProps throughout the React codebase and reactors them to serially stable default function parameters.

Changelog

New

  • Added a internal/noopFn export that is used anywhere we were setting a default value on a change handler i.e onChange: () => {} becomes onChange = noopFn

Changed

  • Removed default props and instead set default function parameters for these default values.
  • Updated some tests and stories to account for required props that need to be explicitly provided

Removed

  • I removed some isRequired props that were not required in other places, or would throw unnecessary console warnings if the prop was not explicitly provided (even though we set a default).

Testing / Reviewing

  • For each component modified, go to their story and ensure no console warnings appear.
  • Ensure removed isRequired props are okay
  • Double check DataTable and Listbox components, as these were some of the more heavily modified components

@netlify
Copy link

netlify bot commented Sep 26, 2023

Deploy Preview for v11-carbon-react ready!

Name Link
🔨 Latest commit ded0ff8
🔍 Latest deploy log https://app.netlify.com/sites/v11-carbon-react/deploys/65134468b96e2800089a174c
😎 Deploy Preview https://deploy-preview-14720--v11-carbon-react.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@netlify
Copy link

netlify bot commented Sep 26, 2023

Deploy Preview for carbon-elements ready!

Name Link
🔨 Latest commit ded0ff8
🔍 Latest deploy log https://app.netlify.com/sites/carbon-elements/deploys/651344686da44f0008dad047
😎 Deploy Preview https://deploy-preview-14720--carbon-elements.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@netlify
Copy link

netlify bot commented Sep 26, 2023

Deploy Preview for v11-carbon-react ready!

Name Link
🔨 Latest commit 0334255
🔍 Latest deploy log https://app.netlify.com/sites/v11-carbon-react/deploys/653136ab7620b70008d4a652
😎 Deploy Preview https://deploy-preview-14720--v11-carbon-react.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@netlify
Copy link

netlify bot commented Sep 26, 2023

Deploy Preview for carbon-elements ready!

Name Link
🔨 Latest commit 0334255
🔍 Latest deploy log https://app.netlify.com/sites/carbon-elements/deploys/653136ab3803d6000813c34f
😎 Deploy Preview https://deploy-preview-14720--carbon-elements.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@tw15egan tw15egan marked this pull request as ready for review October 3, 2023 19:15
@tw15egan tw15egan requested review from a team as code owners October 3, 2023 19:15
Copy link
Member

@tay1orjones tay1orjones left a comment

Choose a reason for hiding this comment

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

Lots to parse in the diff, but this looks good from my view.

@tay1orjones
Copy link
Member

Would you mind updating the checklist on #13424 with the ones here that you've migrated over to default function params? If the list ends up being complete we can close that one as well

@tw15egan
Copy link
Member Author

Updated, the only one missing is Slider, which we can do once #14297 is done

Copy link
Contributor

@andreancardona andreancardona left a comment

Choose a reason for hiding this comment

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

Tested on my end and looks good!

@tw15egan
Copy link
Member Author

@tay1orjones @andreancardona I've updated this PR to include Slider, so there should be no more instances of defaultProps in the repo

@tw15egan tw15egan added this pull request to the merge queue Oct 19, 2023
Merged via the queue into carbon-design-system:main with commit 2ebd2cb Oct 19, 2023
17 checks passed
@tw15egan tw15egan deleted the remove-default-props branch October 19, 2023 15:26
@tay1orjones tay1orjones added this to the 2023 Q4 milestone Oct 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
3 participants