javascript - 使用从“react-native-image-crop-picker”导入 ImagePicker 时出错;
问题描述
我正在尝试打开用户的画廊,以便他/她可以选择图像,并且我为此目的使用 react-native-image-crop-picker 模块,但我收到此错误:TypeError: null is not an object (evaluating ' _reactNativeImageCropPicker.default.openPicker')我使用这个来自https://github.com/ivpusic/react-native-image-crop-picker
import React from "react";
import { View, Text, StyleSheet, TextInput, NativeModules } from "react-native";
import ActionButton from "react-native-action-button";
import Icon from "react-native-vector-icons/Ionicons";
import ImagePicker from "react-native-image-crop-picker";
const ChooseImg = () => {
ImagePicker.openPicker({
width: 300,
height: 400,
cropping: false,
}).then((image) => {
console.log(image);
});
};
export default function AddPost() {
const PostBtn = () => {
return (
<>
<View style={styles.container}>
<TextInput
style={styles.PostInputStyle}
placeholder="What's on your mind?"
/>
</View>
<ActionButton buttonColor="#7b68ee">
<ActionButton.Item
buttonColor="#9b59b6"
title="Camera"
onPress={() => console.log("Camera tapped!")}
>
<Icon name="camera-outline" style={styles.actionButtonIcon} />
</ActionButton.Item>
<ActionButton.Item
buttonColor="#3498db"
title="Choose pictures"
onPress={() => {
console.log("Choose pictures tapped!");
ChooseImg();
}}
>
<Icon name="md-images-outline" style={styles.actionButtonIcon} />
</ActionButton.Item>
</ActionButton>
</>
);
};
return (
<>
<PostBtn />
</>
);
}
const styles = StyleSheet.create({
container: {
display: "flex",
justifyContent: "center",
alignItems: "center",
backgroundColor: "#f4f5f7",
},
PostInputStyle: {
fontSize: 25,
marginTop: 60,
fontWeight: "bold",
},
});
解决方案
推荐阅读
- java - Java - 定义几个自定义异常而不重写每个异常(干)
- java - @ManyToOne 没有在 Child 表中保留 Parent FKey 列
- javascript - 如何处理对客户端反应应用程序的外部重定向?
- javascript - 为什么 .indexof() 返回 -1;当项目存在于给定数组中时?| 谷歌脚本
- mysql - MySQL 在另一个查询中使用查询
- symfony4 - 如何将 hydra apiplatform 文档转换为 Swagger 规范 (OAS3)?
- sql-server - 我的数据库中的数据显示为问号
- flutter - 在构建函数之外使用 BuildContext
- ruby-on-rails - 使用外键作为复合键的一部分
- sql - 每天将数据从一个 SQL Server 数据库复制到另一个 SQL 数据库