react-native-swiper icon indicating copy to clipboard operation
react-native-swiper copied to clipboard

Can not update call state in onIndexChanged callback

Open kecsou opened this issue 4 years ago • 7 comments

Hello I got an error when I updated my State on the callback of my function onIndexChanged. "Warning: Cannot update a component from inside the function body of a different component."

kecsou avatar Sep 30 '20 15:09 kecsou

while they fix the problem, that work for me:

const updateIndex = useCallback((res) => { setTimeout(() => { setCurrentIndex(res); }, 50); }, []);

wrap the state update inside a timeout :S

pablortsal avatar Oct 05 '20 14:10 pablortsal

Hello. Any other alternatives how to get current index while we wait for the fix?

milennaj avatar Oct 22 '20 15:10 milennaj

Any updates?

suraneti avatar Oct 30 '20 09:10 suraneti

same issue. any other solution?

huurray avatar Nov 09 '20 01:11 huurray

Any update on this? I'm also getting this warning.

kyle-ahlstrom avatar Feb 05 '21 16:02 kyle-ahlstrom

... still ?

danilocanalle avatar Jun 10 '21 16:06 danilocanalle

Nothing? 😢

jacprada avatar Jan 13 '22 12:01 jacprada