Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

beforeChange() breaks fade #1214

Open
mcfoton opened this issue May 3, 2018 · 5 comments
Open

beforeChange() breaks fade #1214

mcfoton opened this issue May 3, 2018 · 5 comments

Comments

@mcfoton
Copy link

mcfoton commented May 3, 2018

Sandbox: https://codesandbox.io/s/2j3onlv9rn
Removing either beforeChange() or fade restores normal behaviour. But I would want to use both :)

NOTE: changing to afterChange() will make slider work, but still mess up the state changes.

@VasiliyBP
Copy link

Same issue

@mohdsayed
Copy link

I had the same issue. And what I noticed is that if you setState on beforeChange with fade: true, it breaks the sliders. The kind of hack I used was to delay my setState by 10 milliseconds using setTimeout() and then it works fine.

@akiran Can you give some insight as why it happens?

@engmsilva
Copy link

I was having the same problem with the React Hooks fade, I disabled this option in the project and everything went back to normal.

@TianboZ
Copy link

TianboZ commented Jul 2, 2020

I was using react hook, but @sayedtaqui hack doesn't work for me

const [slideState, setSlideState] = useState({
		activeSlide: 0,
		activeSlide2: 0
	});

beforeChange: (current, next) => {
			setTimeout(() =>{
				setSlideState({...slideState, activeSlide: next})

			}, 10)
		},
		 afterChange: current => {
				 setSlideState( {...slideState, activeSlide2: current} );
		 },

@bichan17
Copy link

bichan17 commented Jul 23, 2020

In my case, the slider would not change slides unless you clicked twice, and beforeChange would get called on the second click.

I was able to work around this bug using setTimeout like so:

beforeChange: (current, next) => { setTimeout(() => onSlideChange(next), 10); }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants