Skip to content

Creating a expo , react native template using slush :  #63

@NaveenDK

Description

@NaveenDK

Hi All,
I am trying to create a (expo) react native template using slush,

  1. the react native app works fine in EXPO XDE
  2. when I run slush command with the above project (which works fine in XDE) gives the following error:
    Reference Error ^ match is not defined

The code related to the above is:


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',
              },
            });

          }

  }

Thanks in advance, Slush article I referred: https://medium.com/@horte/how-to-create-a-slush-generator-part-1-eafece6c1ca8
please note that I won;t get such errors when I try generating reactjs webapps ,
Thanks in advance
Naveen

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions