leecade / leecade/react-native-swiper
Wrong height of slider item when component is rerendered
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 ?
Mac OSX 10.14
Version
Which versions are you using:
- react-native-swiper v? 1.6.0-rc.1
- react-native v0.?.? 0.61.5
Expected behaviour
- The height should be calculated correctly.
Actual behaviour
- I have header block ( blue box ) and two slides ( red box ), when I swipe to second slide, I set the
currentSlideindex usingonIndexChangemethod. After switched to second slide, it "jumps over" the screen. - However, when I remove
setSlide(index), it works perfectly.
How to reproduce it>
To help us, please fork this component, modify one example in examples folder to reproduce your issue and include link here.
Steps to reproduce
Code:
const [currentSlide, setSlide] = useState(0)
onIndexChange = (index) => {
setSlide(index)
}
<BlueBox />
<Swiper
horizontal={false}
dot={false}
showsPagination={false}
loop={false}
onIndexChanged={onIndexChange}
index={currentSlide}
>
<RedBox />
<RedBox />
</Swiper>
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
Start with the Swiper example in the examples folder and reproduce the jump using the shown currentSlide state, onIndexChanged callback, vertical mode, and index prop. Compare the slider item's calculated height before and after rerendering, and consider the issue done when switching to the second slide no longer causes the screen to jump.
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
- Mostly clear
- Newbie friendliness
- 35/100