Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
NaveenDK opened this issue Jan 9, 2018 · 0 comments
Open

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

NaveenDK opened this issue Jan 9, 2018 · 0 comments

Comments

@NaveenDK
Copy link

NaveenDK commented Jan 9, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant