Skip to content

Commit 5f6213c

Browse files
infostreamsExilz
authored andcommitted
Work around a bug in FlatList
More or less the same as meliorence/react-native-snap-carousel@24731a0
1 parent e62907c commit 5f6213c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/libraries/ViewPager/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,14 @@ export default class ViewPager extends PureComponent {
108108

109109
const finalX = this.getScrollOffsetOfPage(page);
110110
this.scroller.startScroll(this.scroller.getCurrX(), 0, finalX - this.scroller.getCurrX(), 0, 0);
111+
112+
requestAnimationFrame(() => {
113+
// this is here to work around a bug in FlatList, as discussed here
114+
// https://github.com/facebook/react-native/issues/1831
115+
// (and solved here https://github.com/facebook/react-native/commit/03ae65bc ?)
116+
this.scrollByOffset(1);
117+
this.scrollByOffset(-1);
118+
});
111119
}
112120

113121
componentDidUpdate (prevProps) {

0 commit comments

Comments
 (0)