You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Setting the index prop to the previous value does not switch rendered index. Upon re-renders of the SwipeableViews component, if the previous render's index value is the same, nothing happens. Even if the user interacted with the component between renders and thus the index has changed.
I have searched the issues of this repository and believe that this is not a duplicate.
Expected Behavior
Updating the index prop on a re-renders of SwipeableViews should always change the view to that slide.
Current Behavior
The view only changes to the specific index based on previous index values. Sometimes different values do not cause a slide change when it should.
Set the initial index prop to undefined. First render is on index 0 as expect.
Interact with the slider to go to a different index. In the demo swipe to slide 3.
Cause an event which re-renders the SwipeableViews component, now set index to 1. In the demo click the Go back to the first slide button
Component should animate back to index 0. Instead nothing happens on the re-render.
If you change the setIndex(0) call to 1 instead of 0 in my demo, it will correctly go to that slide, however only once. This appears to relate to not being able to go to the index value of the previous render.
Context
In my application I'm attempting to go "back" to the initial slide if something happens asynchronously. However due to this bug I'm having to side step it by unmounting the component then re-rendering it, which makes me lose the slick animation unfortunately.
Your Environment
Tech
Version
react-swipeable-views
0.13.3
React
16.10.2
platform
browser
The text was updated successfully, but these errors were encountered:
Setting the
index
prop to the previous value does not switch rendered index. Upon re-renders of theSwipeableViews
component, if the previous render'sindex
value is the same, nothing happens. Even if the user interacted with the component between renders and thus the index has changed.Expected Behavior
Updating the
index
prop on a re-renders ofSwipeableViews
should always change the view to that slide.Current Behavior
The view only changes to the specific index based on previous index values. Sometimes different values do not cause a slide change when it should.
Steps to Reproduce (for bugs)
Demo: https://codesandbox.io/s/material-demo-yrfvv
index
prop toundefined
. First render is on index 0 as expect.SwipeableViews
component, now setindex
to1
. In the demo click theGo back to the first slide
buttonIf you change the
setIndex(0)
call to1
instead of0
in my demo, it will correctly go to that slide, however only once. This appears to relate to not being able to go to the index value of the previous render.Context
In my application I'm attempting to go "back" to the initial slide if something happens asynchronously. However due to this bug I'm having to side step it by unmounting the component then re-rendering it, which makes me lose the slick animation unfortunately.
Your Environment
The text was updated successfully, but these errors were encountered: