Skip to content

Commit

Permalink
Fix #361 cancel timer when tabs component unmounts
Browse files Browse the repository at this point in the history
  • Loading branch information
sosaucily committed Mar 16, 2016
1 parent 752f2cb commit 380da26
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion components/tabs/Tabs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ class Tabs extends React.Component {
this.updatePointer(nextProps.index);
}

componentWillUnmount () {
clearTimeout(this.pointerTimeout);
}

handleHeaderClick = (idx) => {
if (this.props.onChange) this.props.onChange(idx);
};
Expand All @@ -50,7 +54,8 @@ class Tabs extends React.Component {
}

updatePointer (idx) {
setTimeout(() => {
clearTimeout(this.pointerTimeout);
this.pointerTimeout = setTimeout(() => {
const startPoint = this.refs.tabs.getBoundingClientRect().left;
const label = this.refs.navigation.children[idx].getBoundingClientRect();
this.setState({
Expand Down

0 comments on commit 380da26

Please sign in to comment.