Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

expo image picker

expo install expo-image-picker
Comment

expo image picker

import React, { useState, useEffect } from 'react';
import { Button, Image, View, Platform } from 'react-native';
import * as ImagePicker from 'expo-image-picker';

export default function ImagePickerExample() {
  const [image, setImage] = useState(null);

  const pickImage = async () => {
    // No permissions request is necessary for launching the image library
    let result = await ImagePicker.launchImageLibraryAsync({
      mediaTypes: ImagePicker.MediaTypeOptions.All,
      allowsEditing: true,
      aspect: [4, 3],
      quality: 1,
    });

    console.log(result);

    if (!result.cancelled) {
      setImage(result.uri);
    }
  };

  return (
    <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
      <Button title="Pick an image from camera roll" onPress={pickImage} />
      {image && <Image source={{ uri: image }} style={{ width: 200, height: 200 }} />}
    </View>
  );
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: mongo query by object id node js 
Javascript :: clear localstorage on click jquery 
Javascript :: range javascript 
Javascript :: PG::DuplicateTable: ERROR: relation already exists 
Javascript :: how to make a modal stay center of screen 
Javascript :: loop dictionary with key and value javascript 
Javascript :: javascript remove all event listeners 
Javascript :: shadow in react native 
Javascript :: trigger send parameter 
Javascript :: install react js 
Javascript :: Use History React Router v6 app 
Javascript :: react bootstrap card 
Javascript :: how to reverse a string in javascript 
Javascript :: ajax call do something while 
Javascript :: string array to int array javascript 
Javascript :: how to copy to clipboard in react js 
Javascript :: phaser 3 add button 
Javascript :: keypress javascript 
Javascript :: fatal error: ineffective mark-compacts near heap limit allocation failed – javascript heap out of memory 
Javascript :: string replace javascript 
Javascript :: traverse an array in javascript 
Javascript :: import json data in js file 
Javascript :: js send get method 
Javascript :: debug react vscode 
Javascript :: use import in node 
Javascript :: assign an element value as key in array of objects 
Javascript :: prop type for ref in react js 
Javascript :: replace array element javascript 
Javascript :: Capitalise a String 
Javascript :: javascript set width percentage update 
ADD CONTENT
Topic
Content
Source link
Name
6+3 =