From d602b687561625337ed4fa85cb7d1e8c3bbd0420 Mon Sep 17 00:00:00 2001 From: ssuschevsky Date: Sun, 30 Aug 2015 02:30:39 +0500 Subject: [PATCH] Added onSelectTab callback --- src/tabs/index.jsx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/tabs/index.jsx b/src/tabs/index.jsx index 14622c8..9438233 100644 --- a/src/tabs/index.jsx +++ b/src/tabs/index.jsx @@ -8,6 +8,20 @@ var Tabs = React.createClass({ content: null }; }, + componentDidUpdate: function() { + var self = this; + if (typeof this.props.onSelectTab === 'function') { + var props = Object.create({}); + Object.keys(this.props.children[this.state.selectedTab].props) + .filter(function(propKey){ + return propKey !== 'children'; + }) + .forEach(function(propKey) { + props[propKey] = self.props.children[self.state.selectedTab].props[propKey]; + }); + this.props.onSelectTab(props); + } + }, selectTab: function (options) { this.setState(options); },