Skip to content

Commit 6182fbb

Browse files
committed
add support for a id generation function
1 parent cb701e6 commit 6182fbb

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/components/Tabs.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ module.exports = React.createClass({
2727
focus: PropTypes.bool,
2828
children: childrenPropType,
2929
forceRenderTabPanel: PropTypes.bool,
30+
generateIdsFn : PropTypes.func,
3031
},
3132

3233
childContextTypes: {
@@ -169,14 +170,15 @@ module.exports = React.createClass({
169170
const state = this.state;
170171
const tabIds = this.tabIds = this.tabIds || [];
171172
const panelIds = this.panelIds = this.panelIds || [];
173+
const generateIdsFn = this.props.generateIdsFn ? this.props.generateIdsFn : uuid;
172174
let diff = this.tabIds.length - this.getTabsCount();
173175

174176
// Add ids if new tabs have been added
175177
// Don't bother removing ids, just keep them in case they are added again
176178
// This is more efficient, and keeps the uuid counter under control
177179
while (diff++ < 0) {
178-
tabIds.push(uuid());
179-
panelIds.push(uuid());
180+
tabIds.push(generateIdsFn());
181+
panelIds.push(generateIdsFn());
180182
}
181183

182184
// Map children to dynamically setup refs

0 commit comments

Comments
 (0)