--- title: Picking an image --- import { SnackInline } from '~/ui/components/Snippet'; import Video from '~/components/plugins/Video'; import { Terminal } from '~/ui/components/Snippet'; So far we have been using code from React and React Native in our app. React gives us a nice way to build components and React Native gives us pre-built components that work on iOS, Android, and web — like `View`, `Text`, `TouchableOpacity`. React Native does _not_ provide us with an image picker. For this, we can use an Expo library called [expo-image-picker](/versions/latest/sdk/imagepicker): > `expo-image-picker` provides access to the system's UI for selecting images and videos from the phone's library or taking a photo with the camera. ## Installing expo-image-picker To use `expo-image-picker` in our project, we first need to install it. In your project directory, run the following command: This will tell npm (or yarn) to install a version of the `expo-image-picker` library that is compatible with your project. ## Picking an image With the library installed in our project, we can now actually use it. {/* prettier-ignore */} ```js import React from 'react'; import { Image, StyleSheet, Text, TouchableOpacity, View } from 'react-native'; /* @info Import the ImagePicker */import * as ImagePicker from 'expo-image-picker';/* @end */ export default function App() { /* @info Launch the picker and log the result. */ let openImagePickerAsync = async () => { let pickerResult = await ImagePicker.launchImageLibraryAsync(); console.log(pickerResult); } /* @end */ return ( To share a photo from your phone with a friend, just press the button below! Pick a photo ); } ```
You should see something like this when you run your app and use the picker: