-
-
Notifications
You must be signed in to change notification settings - Fork 447
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
base: main
Are you sure you want to change the base?
Conversation
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. |
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.' | ||
); | ||
} |
There was a problem hiding this comment.
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'); |
There was a problem hiding this comment.
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?
🐛 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
defaultProps
with ES6 default parameters in function signaturesFiles Changed
src/components/Tabs.js
src/components/TabList.js
src/components/Tab.js
src/components/TabPanel.js
Testing