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

commit-master picture commit-master  路  3Comments

nomoreboredom picture nomoreboredom  路  3Comments

JonasOmdal picture JonasOmdal  路  3Comments

AndrewSouthpaw picture AndrewSouthpaw  路  3Comments

wrannaman picture wrannaman  路  3Comments