Skip to content

Commit 89450c0

Browse files
authored
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 cb701e6 commit 89450c0

File tree

12 files changed

+50
-57
lines changed

12 files changed

+50
-57
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/TabList.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { PropTypes } from 'react';
22
import cx from 'classnames';
33

44
function renderChildren(props) {
5-
return React.Children.map(props.children, (child) =>
5+
return React.Children.map(props.children, child =>
66
React.cloneElement(child, {
77
activeTabClassName: props.activeTabClassName,
88
disabledTabClassName: props.disabledTabClassName,

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';
@@ -22,9 +21,9 @@ module.exports = React.createClass({
2221

2322
propTypes: {
2423
className: PropTypes.string,
25-
selectedIndex: PropTypes.number,
24+
selectedIndex: PropTypes.number, // eslint-disable-line react/no-unused-prop-types
2625
onSelect: PropTypes.func,
27-
focus: PropTypes.bool,
26+
focus: PropTypes.bool, // eslint-disable-line react/no-unused-prop-types
2827
children: childrenPropType,
2928
forceRenderTabPanel: PropTypes.bool,
3029
},
@@ -59,7 +58,7 @@ module.exports = React.createClass({
5958

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

@@ -98,16 +97,14 @@ module.exports = React.createClass({
9897

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

107105
// If no tab found, continue searching from first on left to index
108106
for (let i = 0; i < index; i++) {
109-
const tab = this.getTab(i);
110-
if (!isTabDisabled(findDOMNode(tab))) {
107+
if (!isTabDisabled(this.getTab(i))) {
111108
return i;
112109
}
113110
}
@@ -121,17 +118,15 @@ module.exports = React.createClass({
121118

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

130126
// If no tab found, continue searching from last tab on right to index
131127
i = this.getTabsCount();
132128
while (i-- > index) {
133-
const tab = this.getTab(i);
134-
if (!isTabDisabled(findDOMNode(tab))) {
129+
if (!isTabDisabled(this.getTab(i))) {
135130
return i;
136131
}
137132
}
@@ -150,16 +145,8 @@ module.exports = React.createClass({
150145
return React.Children.count(this.props.children.slice(1));
151146
},
152147

153-
getTabList() {
154-
return this.refs.tablist;
155-
},
156-
157148
getTab(index) {
158-
return this.refs[`tabs-${index}`];
159-
},
160-
161-
getPanel(index) {
162-
return this.refs[`panels-${index}`];
149+
return this.tabNodes[`tabs-${index}`];
163150
},
164151

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

204-
const ref = `tabs-${index}`;
190+
const tabRef = (node) => { this.tabNodes[`tabs-${index}`] = node; };
205191
const id = tabIds[index];
206192
const panelId = panelIds[index];
207193
const selected = state.selectedIndex === index;
@@ -210,7 +196,7 @@ module.exports = React.createClass({
210196
index++;
211197

212198
return cloneElement(tab, {
213-
ref,
199+
tabRef,
214200
id,
215201
panelId,
216202
selected,
@@ -224,15 +210,13 @@ module.exports = React.createClass({
224210
}
225211
// Clone TabPanel components to have refs
226212
else {
227-
const ref = `panels-${index}`;
228213
const id = panelIds[index];
229214
const tabId = tabIds[index];
230215
const selected = state.selectedIndex === index;
231216

232217
index++;
233218

234219
result = cloneElement(child, {
235-
ref,
236220
id,
237221
tabId,
238222
selected,
@@ -243,6 +227,8 @@ module.exports = React.createClass({
243227
});
244228
},
245229

230+
tabNodes: [],
231+
246232
handleKeyDown(e) {
247233
if (this.isTabFromContainer(e.target)) {
248234
let index = this.state.selectedIndex;
@@ -323,9 +309,8 @@ module.exports = React.createClass({
323309

324310
// Check if the first occurrence of a Tabs container is `this` one.
325311
let nodeAncestor = node.parentElement;
326-
const tabsNode = findDOMNode(this);
327312
do {
328-
if (nodeAncestor === tabsNode) return true;
313+
if (nodeAncestor === this.node) return true;
329314
else if (nodeAncestor.getAttribute('data-tabs')) break;
330315

331316
nodeAncestor = nodeAncestor.parentElement;
@@ -375,6 +360,7 @@ module.exports = React.createClass({
375360
)}
376361
onClick={this.handleClick}
377362
onKeyDown={this.handleKeyDown}
363+
ref={(node) => { this.node = node; }}
378364
data-tabs
379365
>
380366
{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';

0 commit comments

Comments
 (0)