leecade / leecade/react-native-swiper
onMomentumScrollEnd 'event' argument is unusable
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 10.5k
- Forks
- 2.3k
- PR merge metrics
- No merged PRs in 30d
Description
onMomentumScrollEnd event parameter is not a valid event when the function is called.
See here:
https://github.com/leecade/react-native-swiper/blob/master/src/index.js#L363-L369
I think either the event must be 'persist'-ed (calling event.persist()) outside the callback of updateIndex or the event must not be givan at all to onMomentumScrollEnd.
Or at least it must be documented that onMomentumScrollEnd event parameter is not usable.
I have no idea if persisting the event would have a performance impact.
Which OS ?
Android
Version
Which versions are you using:
- react-native-swiper v1.5.13
- react-native v0.48.3
Expected behaviour
We can use the first argument of onMomentumScrollEnd, the event.
Actual behaviour
If we try to use a property of the event, either we get empty or null values or the get a warning (or both) :
Warning: This synthetic event is reused for performance reasons. If you're seeing this, you're accessing the property
typeon a released/nullified synthetic event. This is set to null. If you must keep the original synthetic event around, use event.persist(). See https://fb.me/react-event-pooling for more information.
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
- Build a swiper component
- Add a onMomentumScrollEnd callback
momentumScollEnd(e) {
console.log(e.type);
}
- Launch and swipe
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 at src/index.js lines 363-369 and reproduce the Android behavior using the three listed steps with an onMomentumScrollEnd callback that reads the event type. Compare the callback's event with the React Native event-pooling warning, then verify that the chosen behavior is reflected when swiping; no test file is mentioned in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react-native
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100