@@ -281,29 +281,29 @@ class Slider extends Component {
281281 const { children, vertical, infinite, swipe, draggable } = this . props ;
282282 const { transitionSpeed, transitionTimingFn } = this . props ;
283283 const { beforeChange, afterChange } = this . props ;
284- const [ leftArrow , slides , rightArrow ] = children ;
284+ const [ leftArrow , slides , rightArrow , customComponent ] = children ;
285285 const { currentSlide, translateXOffset, translateYOffset } = this . state ;
286286 const slideCount = Children . count ( slides . props . children ) ;
287287
288288 // onClick is passed as a props so that dom elements can be custom arrows
289289
290- const newLeftArrow = cloneElement ( leftArrow , {
290+ const newLeftArrow = leftArrow !== undefined ? cloneElement ( leftArrow , {
291291 key : 0 ,
292292 handleClick : ( ) => { this . handleSlideShift ( - 1 ) ; } ,
293293 onClick : ( ) => { this . handleSlideShift ( - 1 ) ; } ,
294294 currentSlide,
295295 infinite
296- } ) ;
296+ } ) : null ;
297297
298298 // Need to pass slideCount to check if end of slide has been reached.
299- const newRightArrow = cloneElement ( rightArrow , {
299+ const newRightArrow = rightArrow !== undefined ? cloneElement ( rightArrow , {
300300 key : 2 ,
301301 handleClick : ( ) => { this . handleSlideShift ( 1 ) ; } ,
302302 onClick : ( ) => { this . handleSlideShift ( 1 ) ; } ,
303303 currentSlide,
304304 infinite,
305305 slideCount
306- } ) ;
306+ } ) : null ;
307307
308308 // TODO Show a warning if transitionSpeed prop is declared on Slides.
309309 const newSlides = cloneElement ( slides , {
@@ -329,11 +329,20 @@ class Slider extends Component {
329329 translateYOffset
330330 } ) ;
331331
332+ const newCustomComponent = customComponent !== undefined ? cloneElement ( customComponent , {
333+ currentSlide,
334+ slideCount,
335+ handleSlideShift : ::this . handleSlideShift
336+ } ) : null ;
337+
332338 return (
333- < div ref = "slider" style = { { display : 'flex' , alignItems : 'center' } } >
334- { newLeftArrow }
335- { newSlides }
336- { newRightArrow }
339+ < div >
340+ < div ref = "slider" style = { { display : 'flex' , alignItems : 'center' } } >
341+ { newLeftArrow }
342+ { newSlides }
343+ { newRightArrow }
344+ </ div >
345+ { newCustomComponent }
337346 </ div >
338347 ) ;
339348 }
0 commit comments