File tree 1 file changed +19
-17
lines changed
1 file changed +19
-17
lines changed Original file line number Diff line number Diff line change @@ -266,26 +266,28 @@ const Carousel = React.createClass({
266
266
handleSelect ( index , direction ) {
267
267
clearTimeout ( this . timeout ) ;
268
268
269
- let previousActiveIndex = this . getActiveIndex ( ) ;
270
- direction = direction || this . getDirection ( previousActiveIndex , index ) ;
269
+ if ( this . isMounted ( ) ) {
270
+ let previousActiveIndex = this . getActiveIndex ( ) ;
271
+ direction = direction || this . getDirection ( previousActiveIndex , index ) ;
271
272
272
- if ( this . props . onSelect ) {
273
- this . props . onSelect ( index , direction ) ;
274
- }
275
-
276
- if ( this . props . activeIndex == null && index !== previousActiveIndex ) {
277
- if ( this . state . previousActiveIndex != null ) {
278
- // If currently animating don't activate the new index.
279
- // TODO: look into queuing this canceled call and
280
- // animating after the current animation has ended.
281
- return ;
273
+ if ( this . props . onSelect ) {
274
+ this . props . onSelect ( index , direction ) ;
282
275
}
283
276
284
- this . setState ( {
285
- activeIndex : index ,
286
- previousActiveIndex,
287
- direction
288
- } ) ;
277
+ if ( this . props . activeIndex == null && index !== previousActiveIndex ) {
278
+ if ( this . state . previousActiveIndex != null ) {
279
+ // If currently animating don't activate the new index.
280
+ // TODO: look into queuing this canceled call and
281
+ // animating after the current animation has ended.
282
+ return ;
283
+ }
284
+
285
+ this . setState ( {
286
+ activeIndex : index ,
287
+ previousActiveIndex,
288
+ direction
289
+ } ) ;
290
+ }
289
291
}
290
292
}
291
293
} ) ;
You can’t perform that action at this time.
0 commit comments