小编lsi*_*lva的帖子

无法读取未定义的react-native-image-picker的属性“launchImageLibrary”

我的功能提供了一个小图像图标作为可触摸的按钮来上传或拍照,使用"react-native-image-picker": "^3.3.2"

我收到 error: ,与此GitHub 问题Cannot read property 'launchImageLibrary' of undefined相同,但如您所见,我的代码已经按照他们的指示进行了导入。

这是我的完整代码:

import React from 'react';
import {
    StyleSheet,
    Image,
    TouchableOpacity,
    Alert
} from 'react-native';
import { launchImageLibrary } from 'react-native-image-picker';

const ImageUpload: React.FC<any> = ({}) => {

    function showMessage() {
        Alert.alert("Upload image", "Choose a option", [
            {
                text: 'Camera',
                onPress: () => openCamera(),
            },
            {
                text: 'Gallery',
                onPress: () => openLibrary()
            },
        ]);
    }

    const openLibrary = () => {

        const options = { …
Run Code Online (Sandbox Code Playgroud)

javascript react-native react-native-image-picker

5
推荐指数
1
解决办法
1万
查看次数