This repository was archived by the owner on May 13, 2026. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -266,26 +266,28 @@ const Carousel = React.createClass({
266266 handleSelect ( index , direction ) {
267267 clearTimeout ( this . timeout ) ;
268268
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 ) ;
271272
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 ) ;
282275 }
283276
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+ }
289291 }
290292 }
291293} ) ;
You can’t perform that action at this time.
0 commit comments