From dc34bdb68f37b298818bc24ab345ea02e3cb47b9 Mon Sep 17 00:00:00 2001 From: levente kiraly Date: Fri, 21 Apr 2023 15:34:39 +0200 Subject: [PATCH] fix: refactor defaultProps to disable warning from react (#518) Co-authored-by: Daniel Tschinder <231804+danez@users.noreply.github.com> --- src/components/Tab.js | 9 ++++++--- src/components/TabList.js | 7 +++++-- src/components/TabPanel.js | 7 +++++-- src/components/Tabs.js | 20 ++++++++++++++------ src/components/UncontrolledTabs.js | 8 ++++++-- 5 files changed, 36 insertions(+), 15 deletions(-) diff --git a/src/components/Tab.js b/src/components/Tab.js index f120b891a7..b9d023e01f 100644 --- a/src/components/Tab.js +++ b/src/components/Tab.js @@ -47,7 +47,10 @@ const Tab = (props) => { tabIndex, tabRef, ...attributes - } = props; + } = { + ...defaultProps, + ...props, + }; useEffect(() => { if (selected && focus) { @@ -78,8 +81,8 @@ const Tab = (props) => { ); }; -Tab.propTypes = propTypes; +Tab.propTypes = propTypes; Tab.tabsRole = 'Tab'; -Tab.defaultProps = defaultProps; + export default Tab; diff --git a/src/components/TabList.js b/src/components/TabList.js index 425bc83178..f4686434c2 100644 --- a/src/components/TabList.js +++ b/src/components/TabList.js @@ -14,7 +14,10 @@ const propTypes = { ]), }; const TabList = (props) => { - const { children, className, ...attributes } = props; + const { children, className, ...attributes } = { + ...defaultProps, + ...props, + }; return (