leecade / leecade/react-native-swiper
onIndexChanged produces Warning: Cannot update a component from inside the function body of a different component.
Open
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 10.5k
- Forks
- 2.3k
- PR merge metrics
- No merged PRs in 30d
Description
Which OS ?
iOS
Version
Which versions are you using:
- react-native-swiper v1.6.0
- react-native v0.63.2
Expected behaviour
No errors/warnings?
Actual behaviour
This code produces a warning, Warning: Cannot update a component from inside the function body of a different component..
import React, {useState} from 'react';
import Swiper from 'react-native-swiper';
const [swiperIndex, setSwiperIndex] = useState(0);
const testComponent = () => {
return <Swiper style={styles.wrapper} onIndexChanged={(i) => setSwiperIndex(i)}>
}
export default testComponent;
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the warning on iOS using react-native-swiper v1.6.0 and React Native v0.63.2 with the provided onIndexChanged callback. Start at the onIndexChanged entry point and trace the callback behavior; done means the example no longer emits the reported component-update warning.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react-native
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100