From c0f6a61b7f16d0431cb3e0acba3222bf86d9cc05 Mon Sep 17 00:00:00 2001 From: Ahmet Can Aydemir Date: Tue, 2 Mar 2021 19:06:10 +0300 Subject: [PATCH] fix #1 added componentWillUnmount --- dist/index.js | 5 +++++ package.json | 2 +- src/react-advanced-news-ticker/index.js | 3 +++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/dist/index.js b/dist/index.js index 737e1b8..73811d3 100644 --- a/dist/index.js +++ b/dist/index.js @@ -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() { diff --git a/package.json b/package.json index b09b027..9003bf8 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/react-advanced-news-ticker/index.js b/src/react-advanced-news-ticker/index.js index 04cda84..2ebb9ed 100644 --- a/src/react-advanced-news-ticker/index.js +++ b/src/react-advanced-news-ticker/index.js @@ -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`;