I have been trying to implement the use of gifted-chat and expo-image-picker to have in my app the functions take photo & choose image working.
Anyhow I was not being able to see any response. Basically I could try to click on either function and it was not responding.
I used await pickImage(onSend).catch(console.error);
and now at least I get that error.
Would anyone have an Idea on how I could try to correct the following function:
import { Alert, Image, StyleSheet, Text, TouchableOpacity, View } from "react-native";
import { useActionSheet } from "@expo/react-native-action-sheet";
import * as ImagePicker from "expo-image-picker";
import * as Location from "expo-location";
import { uploadBytes, ref, getDownloadURL } from "firebase/storage";
import { useCallback, useEffect, useState } from "react";
const CustomActions = ({ wrapperStyle, iconTextStyle, onSend, storage, userID }) => {
const actionSheet = useActionSheet()
const [image, setImage] = useState(null);
const onActionPress = useCallback(() => {
const options = ["Choose From Library", "Take Picture", "Send Location", "Cancel"];
const cancelButtonIndex = options.length - 1;
actionSheet.showActionSheetWithOptions({
options, cancelButtonIndex,
},
async (buttonIndex) => {
switch (buttonIndex) {
case 0:
await pickImage(onSend).catch(console.error);
console.log("user wants to choose pick");
return;
case 1:
await takePhoto(onSend).catch(console.error);
console.log("user wants to take pick");
return;
case 2:
await getLocation().catch(console.error);
default:
}
},
)
});
…
That will be passed to the component where it should be rendered within gifted-chat:
const renderCustomActions = (props) => {
return <CustomActions userID={userID} onSend={onSend} storage={storage} {...props} />;
};
…
<GiftedChat
messages={messages}
renderBubble={renderBubble}
onSend={messages=> onSend(messages)}
renderInputToolbar={renderInputToolbar}
renderActions={renderCustomActions}
renderCustomView={renderCustomView}
…
I have tried to use the example from expo-docs to implement but I seem not to come around.
I have SDK 48,
use nvm 16.13.2
npm 8.1.2