Skip to content

Commit 3bd9935

Browse files
committed
add tab panels
1 parent 6e8229e commit 3bd9935

File tree

2 files changed

+17
-18
lines changed

2 files changed

+17
-18
lines changed

src/components/TabPanel.js

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import React, { PropTypes } from 'react';
1+
import React, { PropTypes, Component } from 'react';
22
import cx from 'classnames';
33

4-
module.exports = React.createClass({
5-
displayName: 'TabPanel',
4+
class TabPanel extends Component {
65

7-
propTypes: {
6+
static propTypes = {
87
children: PropTypes.oneOfType([
98
PropTypes.array,
109
PropTypes.object,
@@ -15,23 +14,20 @@ module.exports = React.createClass({
1514
selected: PropTypes.bool,
1615
style: PropTypes.object,
1716
tabId: PropTypes.string,
18-
},
17+
};
1918

20-
contextTypes: {
19+
static contextTypes = {
2120
forceRenderTabPanel: PropTypes.bool,
22-
},
21+
};
2322

24-
getDefaultProps() {
25-
return {
26-
selected: false,
27-
id: null,
28-
tabId: null,
29-
};
30-
},
23+
static defaultProps = {
24+
selected: false,
25+
id: null,
26+
tabId: null,
27+
};
3128

3229
render() {
3330
const { className, children, selected, id, tabId, style, ...attributes } = this.props;
34-
3531
return (
3632
<div
3733
{...attributes}
@@ -50,5 +46,7 @@ module.exports = React.createClass({
5046
{(this.context.forceRenderTabPanel || selected) ? children : null}
5147
</div>
5248
);
53-
},
54-
});
49+
}
50+
}
51+
52+
export default TabPanel;

src/helpers/childrenPropType.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22
import Tab from '../components/Tab';
33
import TabList from '../components/TabList';
4+
import TabPanel from '../components/TabPanel';
45

56
module.exports = function childrenPropTypes(props, propName) {
67
let error;
@@ -27,7 +28,7 @@ module.exports = function childrenPropTypes(props, propName) {
2728
tabsCount++;
2829
}
2930
});
30-
} else if (child.type.displayName === 'TabPanel') {
31+
} else if (child.type === TabPanel) {
3132
panelsCount++;
3233
} else {
3334
error = new Error(

0 commit comments

Comments
 (0)