Migrate from react-native-pager-view
- import PagerView from 'react-native-pager-view';
+ import { Pager } from 'patine-ui';
- <PagerView style={{ flex: 1 }} initialPage={0} onPageSelected={(e) => setPage(e.nativeEvent.position)} ref={pager}>
+ <Pager style={{ flex: 1 }} value={page} onValueChange={setPage}>
<Welcome key="1" />
<Features key="2" />
- </PagerView>
+ </Pager>
- pager.current?.setPage(1);
+ setPage(1);
| react-native-pager-view | Patine UI |
|---|---|
initialPage | defaultValue, or value to control it |
onPageSelected | onValueChange(index), once a page settles |
setPage(i) / setPageWithoutAnimation(i) | set value (it scrolls without calling onValueChange; instant when the OS reduces motion) |
scrollEnabled | scrollEnabled |
orientation="vertical" | orientation="vertical" |
pageMargin | gap |
onPageScroll / onPageScrollStateChanged | — |
offscreenPageLimit | — (every page renders) |
overdrag / overScrollMode / keyboardDismissMode | — |
Pager is a paging ScrollView, so it needs no native module, runs in Expo Go and on the web (where arrow keys page it), and pairs with PageIndicator for dots. For slides narrower than the screen, loop or autoplay, use Carousel.
See all migration guides for other libraries, and Comparison for when another library is the better choice.