Reputation: 664
I get the error "variable uploadImageAsync cannot be found"
uploadImageAsync = async (uri) => {
console.log("In upload image asnyc!");
}
And this is where I call it from.
_handleImagePicked = async pickerResult => {
let uploadResponse, uploadResult;
this.setState({ uploading: true });
if (!pickerResult.cancelled) {
uploadResponse = await uploadImageAsync(pickerResult.uri);
uploadResult = await uploadResponse.json();
this.setState({ image: uploadResult.location });
}
this.setState({ uploading: false });
};
How can I get around this?
So far I've tried:
async function uploadImageAsync(uri) {
I've also tried:
async uploadImageAsync(uri) {
Upvotes: 1
Views: 5120
Reputation: 2426
If the uploadImageAsync
function defined in the same component, you need call this.uploadImageAsync
.
Otherwise, you must import
it from the other module
or define the function outside the component in the same file.
Upvotes: 5