Skip to content

Commit 9e47da0

Browse files
committed
Update dependencies (#132)
* Update dependencies Remove react-dom peer-dependency and replace all findDOMNode calls * Better tabRef callback * Fix linting * be explicit about travis 6 * Lower peer dependency, we don't need 0.14.7
1 parent 51525b7 commit 9e47da0

File tree

11 files changed

+45
-55
lines changed

11 files changed

+45
-55
lines changed

.babelrc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
{
22
"presets": [
3-
"es2015",
4-
"react",
5-
"stage-1"
3+
"latest",
4+
"react"
5+
],
6+
"plugins": [
7+
"transform-object-rest-spread"
68
]
79
}

.eslintrc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
},
88
"rules": {
99
"react/prefer-es6-class": 0,
10-
"react/prefer-stateless-function": 0
10+
"react/prefer-stateless-function": 0,
11+
"no-plusplus": 0,
12+
"react/jsx-filename-extension": ["error", { "extensions": [".js"] }],
13+
"react/forbid-prop-types": 0,
14+
"jsx-a11y/no-static-element-interactions": 0,
15+
"import/no-extraneous-dependencies": 0
1116
}
1217
}

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ language: node_js
33
node_js:
44
- "4"
55
- "5"
6-
- stable
6+
- "6"
77
script:
88
- npm run lint
99
- npm test

package.json

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,26 +37,26 @@
3737
"react-component"
3838
],
3939
"peerDependencies": {
40-
"react": "^0.14.7 || ^15.0.0",
41-
"react-dom": "^0.14.7 || ^15.0.0"
40+
"react": "^0.14.0 || ^15.0.0"
4241
},
4342
"devDependencies": {
4443
"babel-cli": "^6.9.0",
4544
"babel-core": "^6.9.1",
4645
"babel-eslint": "^6.0.4",
47-
"babel-jest": "^13.0.0",
46+
"babel-jest": "^15.0.0",
4847
"babel-loader": "^6.2.4",
49-
"babel-preset-es2015": "^6.9.0",
48+
"babel-plugin-transform-object-rest-spread": "^6.8.0",
49+
"babel-preset-latest": "^6.14.0",
5050
"babel-preset-react": "^6.5.0",
5151
"babel-preset-stage-1": "^6.5.0",
52-
"cross-env": "^1.0.8",
52+
"cross-env": "^2.0.0",
5353
"enzyme": "^2.3.0",
54-
"eslint": "^2.11.1",
55-
"eslint-config-airbnb": "^9.0.1",
54+
"eslint": "^3.5.0",
55+
"eslint-config-airbnb": "^11.0.0",
5656
"eslint-plugin-import": "^1.8.0",
57-
"eslint-plugin-jsx-a11y": "^1.2.2",
58-
"eslint-plugin-react": "^5.1.1",
59-
"jest-cli": "^13.0.0",
57+
"eslint-plugin-jsx-a11y": "^2.2.2",
58+
"eslint-plugin-react": "^6.2.1",
59+
"jest-cli": "^15.0.0",
6060
"react": "^15.0.0",
6161
"react-addons-test-utils": "^15.0.0",
6262
"react-dom": "^15.0.0",
@@ -70,13 +70,8 @@
7070
"js-stylesheet": "^0.0.1"
7171
},
7272
"jest": {
73-
"automock": false,
7473
"testPathDirs": [
7574
"src"
76-
],
77-
"unmockedModulePathPatterns": [
78-
"node_modules",
79-
"babel"
8075
]
8176
}
8277
}

src/__tests__/main-test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
/* global describe, it, expect */
1+
/* eslint-env jest */
2+
/* eslint-disable import/no-named-as-default-member */
23
import ReactTabs, { Tab, Tabs, TabList, TabPanel } from '../main';
34
import TabComponent from '../components/Tab';
45
import TabListComponent from '../components/TabList';

src/components/Tab.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React, { PropTypes } from 'react';
2-
import { findDOMNode } from 'react-dom';
32
import cx from 'classnames';
43

54
module.exports = React.createClass({
@@ -8,6 +7,7 @@ module.exports = React.createClass({
87
propTypes: {
98
className: PropTypes.string,
109
id: PropTypes.string,
10+
tabRef: PropTypes.func,
1111
focus: PropTypes.bool,
1212
selected: PropTypes.bool,
1313
disabled: PropTypes.bool,
@@ -42,7 +42,7 @@ module.exports = React.createClass({
4242

4343
checkFocus() {
4444
if (this.props.selected && this.props.focus) {
45-
findDOMNode(this).focus();
45+
this.node.focus();
4646
}
4747
},
4848

@@ -71,6 +71,7 @@ module.exports = React.createClass({
7171
[disabledTabClassName]: disabled,
7272
}
7373
)}
74+
ref={(node) => { this.node = node; this.props.tabRef(node); }}
7475
role="tab"
7576
id={id}
7677
aria-selected={selected ? 'true' : 'false'}

src/components/Tabs.js

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React, { PropTypes, cloneElement } from 'react';
2-
import { findDOMNode } from 'react-dom';
32
import cx from 'classnames';
43
import jss from 'js-stylesheet';
54
import uuid from '../helpers/uuid';
@@ -23,9 +22,9 @@ module.exports = React.createClass({
2322

2423
propTypes: {
2524
className: PropTypes.string,
26-
selectedIndex: PropTypes.number,
25+
selectedIndex: PropTypes.number, // eslint-disable-line react/no-unused-prop-types
2726
onSelect: PropTypes.func,
28-
focus: PropTypes.bool,
27+
focus: PropTypes.bool, // eslint-disable-line react/no-unused-prop-types
2928
children: childrenPropType,
3029
forceRenderTabPanel: PropTypes.bool,
3130
},
@@ -60,7 +59,7 @@ module.exports = React.createClass({
6059

6160
componentDidMount() {
6261
if (useDefaultStyles) {
63-
jss(require('../helpers/styles.js')); // eslint-disable-line global-require
62+
jss(require('../helpers/styles')); // eslint-disable-line global-require
6463
}
6564
},
6665

@@ -99,16 +98,14 @@ module.exports = React.createClass({
9998

10099
// Look for non-disabled tab from index to the last tab on the right
101100
for (let i = index + 1; i < count; i++) {
102-
const tab = this.getTab(i);
103-
if (!isTabDisabled(findDOMNode(tab))) {
101+
if (!isTabDisabled(this.getTab(i))) {
104102
return i;
105103
}
106104
}
107105

108106
// If no tab found, continue searching from first on left to index
109107
for (let i = 0; i < index; i++) {
110-
const tab = this.getTab(i);
111-
if (!isTabDisabled(findDOMNode(tab))) {
108+
if (!isTabDisabled(this.getTab(i))) {
112109
return i;
113110
}
114111
}
@@ -122,17 +119,15 @@ module.exports = React.createClass({
122119

123120
// Look for non-disabled tab from index to first tab on the left
124121
while (i--) {
125-
const tab = this.getTab(i);
126-
if (!isTabDisabled(findDOMNode(tab))) {
122+
if (!isTabDisabled(this.getTab(i))) {
127123
return i;
128124
}
129125
}
130126

131127
// If no tab found, continue searching from last tab on right to index
132128
i = this.getTabsCount();
133129
while (i-- > index) {
134-
const tab = this.getTab(i);
135-
if (!isTabDisabled(findDOMNode(tab))) {
130+
if (!isTabDisabled(this.getTab(i))) {
136131
return i;
137132
}
138133
}
@@ -151,16 +146,8 @@ module.exports = React.createClass({
151146
return React.Children.count(this.props.children.slice(1));
152147
},
153148

154-
getTabList() {
155-
return this.refs.tablist;
156-
},
157-
158149
getTab(index) {
159-
return this.refs[`tabs-${index}`];
160-
},
161-
162-
getPanel(index) {
163-
return this.refs[`panels-${index}`];
150+
return this.tabNodes[`tabs-${index}`];
164151
},
165152

166153
getChildren() {
@@ -194,15 +181,14 @@ module.exports = React.createClass({
194181
if (count++ === 0) {
195182
// TODO try setting the uuid in the "constructor" for `Tab`/`TabPanel`
196183
result = cloneElement(child, {
197-
ref: 'tablist',
198184
children: React.Children.map(child.props.children, (tab) => {
199185
// null happens when conditionally rendering TabPanel/Tab
200186
// see https://github.com/rackt/react-tabs/issues/37
201187
if (tab === null) {
202188
return null;
203189
}
204190

205-
const ref = `tabs-${index}`;
191+
const tabRef = (node) => { this.tabNodes[`tabs-${index}`] = node; };
206192
const id = tabIds[index];
207193
const panelId = panelIds[index];
208194
const selected = state.selectedIndex === index;
@@ -212,7 +198,7 @@ module.exports = React.createClass({
212198

213199
if (tab.type === Tab) {
214200
return cloneElement(tab, {
215-
ref,
201+
tabRef,
216202
id,
217203
panelId,
218204
selected,
@@ -229,15 +215,13 @@ module.exports = React.createClass({
229215
}
230216
// Clone TabPanel components to have refs
231217
else {
232-
const ref = `panels-${index}`;
233218
const id = panelIds[index];
234219
const tabId = tabIds[index];
235220
const selected = state.selectedIndex === index;
236221

237222
index++;
238223

239224
result = cloneElement(child, {
240-
ref,
241225
id,
242226
tabId,
243227
selected,
@@ -248,6 +232,8 @@ module.exports = React.createClass({
248232
});
249233
},
250234

235+
tabNodes: [],
236+
251237
handleKeyDown(e) {
252238
if (this.isTabFromContainer(e.target)) {
253239
let index = this.state.selectedIndex;
@@ -328,9 +314,8 @@ module.exports = React.createClass({
328314

329315
// Check if the first occurrence of a Tabs container is `this` one.
330316
let nodeAncestor = node.parentElement;
331-
const tabsNode = findDOMNode(this);
332317
do {
333-
if (nodeAncestor === tabsNode) return true;
318+
if (nodeAncestor === this.node) return true;
334319
else if (nodeAncestor.getAttribute('data-tabs')) break;
335320

336321
nodeAncestor = nodeAncestor.parentElement;
@@ -380,6 +365,7 @@ module.exports = React.createClass({
380365
)}
381366
onClick={this.handleClick}
382367
onKeyDown={this.handleKeyDown}
368+
ref={(node) => { this.node = node; }}
383369
data-tabs
384370
>
385371
{this.getChildren()}

src/components/__tests__/Tab-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* global jest, describe, it, expect */
1+
/* eslint-env jest */
22
import React from 'react';
33
import { shallow } from 'enzyme';
44
import Tab from '../Tab';

src/components/__tests__/TabList-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* global jest, describe, it, expect */
1+
/* eslint-env jest */
22
import React from 'react';
33
import { shallow, mount } from 'enzyme';
44
import Tab from '../Tab';

src/components/__tests__/TabPanel-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* global jest, describe, it, expect */
1+
/* eslint-env jest */
22
import React from 'react';
33
import { shallow } from 'enzyme';
44
import TabPanel from '../TabPanel';

0 commit comments

Comments
 (0)