Skip to main content

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-viewingPatine UI
images: ImageSource[]images: { source, alt? }[]
imageIndexvalue (or defaultValue)
onImageIndexChangeonValueChange
visible / onRequestCloseopen / onOpenChange(false)
swipeToCloseEnabledswipeToClose
doubleTapToZoomEnabledalways 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.