React-native-swiper: Can not update call state in onIndexChanged callback

Created on 30 Sep 2020  路  5Comments  路  Source: leecade/react-native-swiper

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."

Most helpful comment

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

All 5 comments

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

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

Any updates?

same issue. any other solution?

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nomoreboredom picture nomoreboredom  路  3Comments

itinance picture itinance  路  3Comments

tokict picture tokict  路  3Comments

commit-master picture commit-master  路  3Comments

Liqiankun picture Liqiankun  路  3Comments