Skip to content

Commit 363086b

Browse files
feat: support react v19
This also removes some of the prop-type checks as react v19 does not support it anymore
1 parent 153f508 commit 363086b

File tree

8 files changed

+61
-63
lines changed

8 files changed

+61
-63
lines changed

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"react-component"
4646
],
4747
"peerDependencies": {
48-
"react": "^18.0.0"
48+
"react": "^18.0.0 || ^19.0.0"
4949
},
5050
"devDependencies": {
5151
"@babel/cli": "7.26.4",
@@ -79,8 +79,8 @@
7979
"mini-css-extract-plugin": "2.9.2",
8080
"prettier": "3.4.2",
8181
"prism-react-renderer": "2.4.1",
82-
"react": "18.3.1",
83-
"react-dom": "18.3.1",
82+
"react": "19.0.0",
83+
"react-dom": "19.0.0",
8484
"react-live": "4.1.8",
8585
"react-modal": "3.16.3",
8686
"webpack": "5.97.1",

pnpm-lock.yaml

+35-40
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/Tab.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import PropTypes from 'prop-types';
21
import React, { useEffect, useRef } from 'react';
32
import cx from 'clsx';
43

@@ -12,6 +11,8 @@ const defaultProps = {
1211
selectedClassName: `${DEFAULT_CLASS}--selected`,
1312
};
1413

14+
/*
15+
Left for TS migration
1516
const propTypes = {
1617
children: PropTypes.oneOfType([
1718
PropTypes.array,
@@ -31,7 +32,7 @@ const propTypes = {
3132
selectedClassName: PropTypes.string,
3233
tabIndex: PropTypes.string,
3334
tabRef: PropTypes.func, // private
34-
};
35+
};*/
3536

3637
const Tab = (props) => {
3738
let nodeRef = useRef();
@@ -82,7 +83,6 @@ const Tab = (props) => {
8283
);
8384
};
8485

85-
Tab.propTypes = propTypes;
8686
Tab.tabsRole = 'Tab';
8787

8888
export default Tab;

src/components/TabList.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
1-
import PropTypes from 'prop-types';
21
import React from 'react';
32
import cx from 'clsx';
43

54
const defaultProps = {
65
className: 'react-tabs__tab-list',
76
};
7+
8+
/*
9+
Left for TS migration
810
const propTypes = {
911
children: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
1012
className: PropTypes.oneOfType([
1113
PropTypes.string,
1214
PropTypes.array,
1315
PropTypes.object,
1416
]),
15-
};
17+
};*/
1618
const TabList = (props) => {
1719
const { children, className, ...attributes } = {
1820
...defaultProps,
@@ -27,6 +29,5 @@ const TabList = (props) => {
2729
};
2830

2931
TabList.tabsRole = 'TabList';
30-
TabList.propTypes = propTypes;
3132

3233
export default TabList;

src/components/TabPanel.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import PropTypes from 'prop-types';
21
import React from 'react';
32
import cx from 'clsx';
43

@@ -8,6 +7,9 @@ const defaultProps = {
87
forceRender: false,
98
selectedClassName: `${DEFAULT_CLASS}--selected`,
109
};
10+
11+
/*
12+
Left for TS migration
1113
const propTypes = {
1214
children: PropTypes.node,
1315
className: PropTypes.oneOfType([
@@ -20,6 +22,7 @@ const propTypes = {
2022
selected: PropTypes.bool, // private
2123
selectedClassName: PropTypes.string,
2224
};
25+
*/
2326
const TabPanel = (props) => {
2427
const {
2528
children,
@@ -50,6 +53,5 @@ const TabPanel = (props) => {
5053
};
5154

5255
TabPanel.tabsRole = 'TabPanel';
53-
TabPanel.propTypes = propTypes;
5456

5557
export default TabPanel;

src/components/Tabs.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import PropTypes from 'prop-types';
1+
import { checkPropTypes } from 'prop-types';
22
import React, { useEffect, useState } from 'react';
33
import {
44
childrenPropType,
@@ -12,6 +12,10 @@ const MODE_CONTROLLED = 0;
1212
const MODE_UNCONTROLLED = 1;
1313
const propTypes = {
1414
children: childrenPropType,
15+
onSelect: onSelectPropType,
16+
selectedIndex: selectedIndexPropType,
17+
/*
18+
Left for TS migration
1519
className: PropTypes.oneOfType([
1620
PropTypes.string,
1721
PropTypes.array,
@@ -27,10 +31,8 @@ const propTypes = {
2731
environment: PropTypes.object,
2832
focusTabOnClick: PropTypes.bool,
2933
forceRenderTabPanel: PropTypes.bool,
30-
onSelect: onSelectPropType,
31-
selectedIndex: selectedIndexPropType,
3234
selectedTabClassName: PropTypes.string,
33-
selectedTabPanelClassName: PropTypes.string,
35+
selectedTabPanelClassName: PropTypes.string,*/
3436
};
3537
const defaultProps = {
3638
defaultFocus: false,
@@ -68,6 +70,7 @@ For more information about controlled and uncontrolled mode of react-tabs see ht
6870
* It is initialized from the prop defaultFocus, and after the first render it is reset back to false. Later it can become true again when using keys to navigate the tabs.
6971
*/
7072
const Tabs = (props) => {
73+
checkPropTypes(propTypes, props, 'prop', 'Tabs');
7174
const {
7275
children,
7376
defaultFocus,
@@ -136,7 +139,6 @@ const Tabs = (props) => {
136139
return <UncontrolledTabs {...subProps}>{children}</UncontrolledTabs>;
137140
};
138141

139-
Tabs.propTypes = propTypes;
140142
Tabs.tabsRole = 'Tabs';
141143

142144
export default Tabs;

src/components/UncontrolledTabs.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import PropTypes from 'prop-types';
1+
import { checkPropTypes } from 'prop-types';
22
import React, { cloneElement, useRef, useId } from 'react';
33
import cx from 'clsx';
44
import { childrenPropType } from '../helpers/propTypes';
@@ -49,6 +49,8 @@ const defaultProps = {
4949

5050
const propTypes = {
5151
children: childrenPropType,
52+
/*
53+
Left for TS migration
5254
direction: PropTypes.oneOf(['rtl', 'ltr']),
5355
className: PropTypes.oneOfType([
5456
PropTypes.string,
@@ -65,10 +67,11 @@ const propTypes = {
6567
selectedIndex: PropTypes.number.isRequired,
6668
selectedTabClassName: PropTypes.string,
6769
selectedTabPanelClassName: PropTypes.string,
68-
environment: PropTypes.object,
70+
environment: PropTypes.object,*/
6971
};
7072

7173
const UncontrolledTabs = (props) => {
74+
checkPropTypes(propTypes, props, 'prop', 'UncontrolledTabs');
7275
let tabNodes = useRef([]);
7376
let tabIds = useRef([]);
7477
const ref = useRef();
@@ -404,6 +407,4 @@ const UncontrolledTabs = (props) => {
404407
);
405408
};
406409

407-
UncontrolledTabs.propTypes = propTypes;
408-
409410
export default UncontrolledTabs;

src/components/__tests__/Tabs-errors-test.js

-3
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@ describe('<Tabs />', () => {
2121
function assertPropTypeWarning(message, nth = 1) {
2222
expect(consoleErrorMock).toHaveBeenNthCalledWith(
2323
nth,
24-
expect.anything(),
25-
expect.anything(),
2624
expect.stringMatching(message),
27-
expect.anything(),
2825
);
2926
}
3027

0 commit comments

Comments
 (0)