admin管理员组文章数量:1430590
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) {
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) {
Share
Improve this question
edited Nov 18, 2017 at 12:40
Andreas
21.9k7 gold badges51 silver badges58 bronze badges
asked Nov 18, 2017 at 12:36
SwimmingGSwimmingG
6643 gold badges9 silver badges33 bronze badges
1
- should you not add a const before uploadImageAsync? – vijayst Commented Nov 18, 2017 at 12:53
1 Answer
Reset to default 5If the uploadImageAsync
function defined in the same ponent, you need call this.uploadImageAsync
.
Otherwise, you must import
it from the other module
or define the function outside the ponent in the same file.
本文标签: javascriptcan39t find variable function declaration react nativeStack Overflow
版权声明:本文标题:javascript - can't find variable function declaration react native - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745458615a2659219.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论