Hi,
I am using the following code in my expo app, which I used and worked fine till I wanted to make template and generate it using slush ,this error may be related to slush (sorry) but I am using expo in my template, and the error shown is related to expo code below:
^
ReferenceError: match is not defined
the code where match is actually included is as follows:
render() {
return (
<View style= {{flex:1}}>
<WebView
source={{uri:'<%= webURI%>'}}
style={{ marginTop: 20 }}
ref={( webView ) => this.webView = webView}
onMessage={
(event)=>{
if(event.nativeEvent.data =="gallery!"){
console.log(event.nativeEvent.data)
this._galleryImage()}
if(event.nativeEvent.data =="camera!"){
console.log(event.nativeEvent.data)
this._cameraImage()}
}}
/>
</View>
)
}
_galleryImage = async () => {
let pickerResult = await ImagePicker.launchImageLibraryAsync({
exif: true,
allowsEditing: false,
quality: 0.7,
base64: true,
})
if (pickerResult.cancelled) {
return
}
console.log(pickerResult)
}
_cameraImage = async() =>{
let result = await ImagePicker.launchCameraAsync({
allowsEditing: true,
aspect: [4, 3],
});
if (result.cancelled) {
return;
}
let localUri = result.uri;
let filename = localUri.split('/').pop();
let match = /\.(\w+)$/.exec(filename);
let type = match ? `image/${match[1]}` : `image`;
let formData = new FormData();
formData.append('photo', { uri: localUri, name: filename, type });
console.log(formData);
return await fetch(YOUR_SERVER_URL, {
method: 'POST',
body: formData,
header: {
'content-type': 'multipart/form-data',
},
});
}
}
I just wanna add that this code is working FINE in the expo XDE but when I run the slush slush-generator with the slush command it gives ‘reference error match is not defined’
Thanks in advance,
Naveen