diff --git a/static/js/directives/components/pages/repo-page/body.tsx b/static/js/directives/components/pages/repo-page/body.tsx index cb4c8add2..b64123a44 100644 --- a/static/js/directives/components/pages/repo-page/body.tsx +++ b/static/js/directives/components/pages/repo-page/body.tsx @@ -9,6 +9,7 @@ interface IBody { interface IBodyState { currentBuild: any; + intervalId: number; } /** @@ -26,11 +27,19 @@ class body extends React.Component { constructor(props){ super(props) this.state = { - currentBuild: [] + currentBuild: [], + intervalId: null }; } componentDidMount() { - setInterval(() => this.getBuilds(), 1000); + let intervalId: number = setInterval(() => this.getBuilds(), 1000); + this.setState({ + currentBuild: this.state.currentBuild, + intervalId: intervalId + }); + } + comoponentDidUnmount() { + clearInterval(this.state.intervalId); } getBuilds() { let api: any = this.props.api; @@ -56,7 +65,8 @@ class body extends React.Component { }); this.setState({ - currentBuild: builds + currentBuild: builds, + intervalId: this.state.intervalId }); }); }