Skip to content

Commit de3cd73

Browse files
author
sagiv.bengiat
committed
prevent onresize calls when unmounted
1 parent 8c89410 commit de3cd73

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-elastic-carousel",
3-
"version": "0.11.5-beta.1",
3+
"version": "0.11.5-beta.2",
44
"description": "A flexible and responsive carousel component for react",
55
"author": "sag1v (Sagiv Ben Giat)",
66
"license": "MIT",

src/react-elastic-carousel/components/Carousel.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,10 @@ class Carousel extends React.Component {
215215
};
216216

217217
onSliderResize = sliderNode => {
218+
if (!this.isComponentMounted) {
219+
return;
220+
}
221+
218222
const {
219223
verticalMode,
220224
children,
@@ -277,7 +281,10 @@ class Carousel extends React.Component {
277281
const containerWidth =
278282
newSliderContainerWidth - (initialVerticalMode ? 0 : outerSpacing * 2);
279283

280-
if (this.state.sliderContainerWidth === newSliderContainerWidth) {
284+
if (
285+
!this.isComponentMounted ||
286+
this.state.sliderContainerWidth === newSliderContainerWidth
287+
) {
281288
// prevent infinite loop
282289
return;
283290
}

0 commit comments

Comments
 (0)