Migrate from react-native-image-viewing
- import ImageView from 'react-native-image-viewing';
+ import { ImageViewer } from 'patine-ui';
- <ImageView images={[{ uri }]} imageIndex={index} visible={open} onRequestClose={() => setOpen(false)} onImageIndexChange={setIndex} />
+ <ImageViewer images={[{ source: { uri }, alt: 'Beach at sunset' }]} value={index} onValueChange={setIndex} open={open} onOpenChange={setOpen} />
| react-native-image-viewing | Patine UI |
|---|---|
images: ImageSource[] | images: { source, alt? }[] |
imageIndex | value (or defaultValue) |
onImageIndexChange | onValueChange |
visible / onRequestClose | open / onOpenChange(false) |
swipeToCloseEnabled | swipeToClose |
doubleTapToZoomEnabled | always on |
backgroundColor / HeaderComponent / FooterComponent | — (a black backdrop, a counter and a close button) |
presentationStyle / animationType | — |
On the web, the arrow keys and arrow buttons move between images, + and − zoom and Escape closes. Name each image with alt for screen readers. See ImageViewer.
See all migration guides for other libraries, and Comparison for when another library is the better choice.