Skip to content

Commit

Permalink
fix #1 added componentWillUnmount
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmetcanaydemir committed Mar 2, 2021
1 parent 2948b54 commit c0f6a61
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ var NewsTicker = function (_Component) {
value: function componentDidMount() {
this.init();
}
}, {
key: "componentWillUnmount",
value: function componentWillUnmount() {
if (this.state.moveInterval) clearInterval(this.state.moveInterval);
}
}, {
key: "init",
value: function init() {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-advanced-news-ticker",
"version": "1.0.0",
"version": "1.0.1",
"main": "dist/index.js",
"scripts": {
"start": "react-scripts start",
Expand Down
3 changes: 3 additions & 0 deletions src/react-advanced-news-ticker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ class NewsTicker extends Component {
componentDidMount() {
this.init();
}
componentWillUnmount() {
if (this.state.moveInterval) clearInterval(this.state.moveInterval);
}

init() {
this.element.current.style.height = `${this.props.rowHeight * this.props.maxRows}px`;
Expand Down

0 comments on commit c0f6a61

Please sign in to comment.