@@ -161,29 +161,37 @@ const SwipeableWrapper = forwardRef(
161161 initialIndex === i ? "auto" : `${ height } px` ;
162162 }
163163 }
164- } , [ ] ) ;
164+ } , [ children . length , initialIndex ] ) ;
165+
166+ useLayoutEffect ( ( ) => {
167+ swipeToIndex ( initialIndex , true ) ;
168+ recalculateStyles ( ) ;
169+ window . addEventListener ( "resize" , recalculateStyles ) ;
170+ return ( ) => {
171+ window . removeEventListener ( "resize" , recalculateStyles ) ;
172+ } ;
173+ } , [ initialIndex , recalculateStyles , swipeToIndex ] ) ;
165174
166175 useLayoutEffect ( ( ) => {
167176 if ( bottomBarRef ?. current ) {
168177 bottomBarRef . current . style . transition = "transform" ;
169178 bottomBarRef . current . style . transitionTimingFunction =
170179 transitionTimingFunction ;
171180 }
172- swipeToIndex ( initialIndex , true ) ;
173- recalculateStyles ( ) ;
181+ } , [ bottomBarRef , transitionTimingFunction ] ) ;
182+
183+ useLayoutEffect ( ( ) => {
174184 const { current : el = null } = elementRef ;
175185 if ( el ) {
176186 el . ontransitionend = onRestFn ;
177187 }
178- window . addEventListener ( "resize" , recalculateStyles ) ;
179188 return ( ) => {
180189 el . ontransitionend = ( ) => { } ;
181- window . removeEventListener ( "resize" , recalculateStyles ) ;
182190 } ;
183- } , [ ] ) ;
191+ } , [ onRestFn ] ) ;
184192
185193 return (
186- < div style = { { overflow : "hidden " , width : "inherit " } } >
194+ < div style = { { width : "inherit " , overflow : "hidden " } } >
187195 < div
188196 { ...bind ( ) }
189197 style = { {
@@ -214,7 +222,7 @@ const SwipeableWrapper = forwardRef(
214222
215223SwipeableWrapper . propTypes = {
216224 bottomBarRef : PropTypes . shape ( {
217- current : PropTypes . objectOf ( PropTypes . object ) ,
225+ current : PropTypes . oneOf ( [ PropTypes . node , PropTypes . object ] ) ,
218226 } ) ,
219227 initialIndex : PropTypes . number ,
220228 onSlideChange : PropTypes . func ,
0 commit comments