Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: migrate from defaultProps to default parameters in all components #587

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

Open
alowelter wants to merge 5 commits into reactjs:main
base: main
Choose a base branch
Loading
from alowelter:main

Conversation

@alowelter
Copy link

@alowelter alowelter commented Aug 21, 2025

🐛 Fix: Remove defaultProps to eliminate React 18 warnings

Problem

React 18 shows deprecation warnings for defaultProps in functional components, as they will be removed in a future release.

Solution

  • Replace defaultProps with ES6 default parameters in function signatures
  • Maintain backward compatibility with existing API
  • No breaking changes

Files Changed

  • src/components/Tabs.js
  • src/components/TabList.js
  • src/components/Tab.js
  • src/components/TabPanel.js

Testing

  • All existing tests pass
  • No breaking changes to public API
  • Warnings eliminated in React 18

Copy link
Collaborator

danez commented Aug 21, 2025
edited
Loading

Thanks i quickly reviewed and looks good, i will check and merge once I'm back from vacation.

And also fix the CI which looks broken.

Comment on lines +60 to +65
if (process.env.NODE_ENV !== 'production' && selectedIndex !== null && defaultIndex !== null) {
console.error(
'The prop `selectedIndex` cannot be used together with `defaultIndex` in `Tabs`.\n' +
'Either remove `selectedIndex` to let `Tabs` handle the selected tab internally or remove `defaultIndex` to handle it yourself.'
);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why was this added? Maybe this conversation from proptypes here should be done in a separate PR.

onSelect,
...attributes
}) => {
checkPropTypes(propTypes, { children, onSelect, selectedIndex }, 'prop', 'Tabs');
Copy link
Collaborator

@danez danez Sep 15, 2025
edited
Loading

Choose a reason for hiding this comment

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

defaultIndex seems missing here. OR was there a reason to no supply all props?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@danez danez danez left review comments

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /