# Migrate from react-native-image-viewing

> Switch from react-native-image-viewing to Patine UI's ImageViewer: the same swipe, pinch, double-tap and swipe-down gestures, open and onOpenChange, a controlled index, and keyboard support on the web.

# Migrate from `react-native-image-viewing`

```diff
- 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`](../../components/image-viewer).

See [all migration guides](./index.mdx) for other libraries, and [Comparison](../comparison.mdx) for when another library is the better choice.
