Skip to content

Commit 86db0c7

Browse files
author
sagiv.bengiat
committed
conditionally state update inside rAF
1 parent de3cd73 commit 86db0c7

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
"test:watch": "react-scripts test --env=jsdom",
2626
"prebuild": "yarn run lint:fix",
2727
"build": "rollup -c",
28-
"prepare": "yarn run build",
2928
"build-doc": "docz build",
3029
"deploy-doc": "gh-pages -d demo"
3130
},

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,11 @@ class Carousel extends React.Component {
206206
// go back from 0ms to whatever set by the user
207207
// We were at 0ms because we wanted to disable animation on resize
208208
// see https://github.com/sag1v/react-elastic-carousel/issues/94
209-
window.requestAnimationFrame(() => this.setState({ transitionMs }));
209+
window.requestAnimationFrame(() => {
210+
if (this.isComponentMounted) {
211+
this.setState({ transitionMs });
212+
}
213+
});
210214
return {
211215
sliderPosition,
212216
activeIndex: newActiveIndex < 0 ? 0 : newActiveIndex

0 commit comments

Comments
 (0)