Skip to content

Conversation

alowelter
Copy link

🐛 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

@alowelter alowelter closed this Aug 21, 2025
@alowelter alowelter reopened this Aug 21, 2025
@danez
Copy link
Collaborator

danez commented Aug 21, 2025

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

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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants