@@ -127,7 +127,10 @@ export function DSlides<ID extends DId, T extends DSlideItem<ID>>(props: DSlides
127127 dataRef . current . clearTid = async . setTimeout (
128128 ( ) => {
129129 dataRef . current . clearTid = undefined ;
130- changeActiveId ( dList [ ( activeIndex + 1 ) % dList . length ] . id ) ;
130+ const id = nth ( dList , ( activeIndex + 1 ) % dList . length ) ?. id ;
131+ if ( ! isUndefined ( id ) ) {
132+ changeActiveId ( id ) ;
133+ }
131134 } ,
132135 autoplay . delay ,
133136 ( ) => {
@@ -219,10 +222,16 @@ export function DSlides<ID extends DId, T extends DSlideItem<ID>>(props: DSlides
219222 }
220223 if ( newIndex === activeIndex ) {
221224 if ( performance . now ( ) - dataRef . current . startDragTime < 300 && Math . abs ( dragDistance ) > 30 ) {
222- changeActiveId ( dList [ Math . max ( newIndex - 1 , 0 ) ] . id ) ;
225+ const id = nth ( dList , Math . max ( newIndex - 1 , 0 ) ) ?. id ;
226+ if ( ! isUndefined ( id ) ) {
227+ changeActiveId ( id ) ;
228+ }
223229 }
224230 } else {
225- changeActiveId ( dList [ newIndex ] . id ) ;
231+ const id = nth ( dList , newIndex ) ?. id ;
232+ if ( ! isUndefined ( id ) ) {
233+ changeActiveId ( id ) ;
234+ }
226235 }
227236 } else {
228237 let newIndex = activeIndex ;
@@ -237,10 +246,16 @@ export function DSlides<ID extends DId, T extends DSlideItem<ID>>(props: DSlides
237246 }
238247 if ( newIndex === activeIndex ) {
239248 if ( performance . now ( ) - dataRef . current . startDragTime < 300 && Math . abs ( dragDistance ) > 30 ) {
240- changeActiveId ( dList [ Math . min ( newIndex + 1 , dList . length - 1 ) ] . id ) ;
249+ const id = nth ( dList , Math . min ( newIndex + 1 , dList . length - 1 ) ) ?. id ;
250+ if ( ! isUndefined ( id ) ) {
251+ changeActiveId ( id ) ;
252+ }
241253 }
242254 } else {
243- changeActiveId ( dList [ newIndex ] . id ) ;
255+ const id = nth ( dList , newIndex ) ?. id ;
256+ if ( ! isUndefined ( id ) ) {
257+ changeActiveId ( id ) ;
258+ }
244259 }
245260 }
246261 }
@@ -363,7 +378,10 @@ export function DSlides<ID extends DId, T extends DSlideItem<ID>>(props: DSlides
363378 tabIndex = { - 1 }
364379 disabled = { activeIndex === 0 }
365380 onClick = { ( ) => {
366- changeActiveId ( dList [ activeIndex - 1 ] . id ) ;
381+ const id = nth ( dList , activeIndex - 1 ) ?. id ;
382+ if ( ! isUndefined ( id ) ) {
383+ changeActiveId ( id ) ;
384+ }
367385 } }
368386 >
369387 < LeftOutlined />
@@ -375,7 +393,10 @@ export function DSlides<ID extends DId, T extends DSlideItem<ID>>(props: DSlides
375393 tabIndex = { - 1 }
376394 disabled = { activeIndex === dList . length - 1 }
377395 onClick = { ( ) => {
378- changeActiveId ( dList [ activeIndex + 1 ] . id ) ;
396+ const id = nth ( dList , activeIndex + 1 ) ?. id ;
397+ if ( ! isUndefined ( id ) ) {
398+ changeActiveId ( id ) ;
399+ }
379400 } }
380401 >
381402 < RightOutlined />
0 commit comments