简体   繁体   中英

Include external javascript file in mobile app built using react native

I'm trying to add cloudinary upload widget to my mobile app built using react native.

The documentation for integrating this widget in app says 'Include javascript file in your webpage.'

Is it possible to include this javascript file in react native for a mobile application?

Whatever I could find online talks about including this file in WebView of react native but that would mean a web application for a mobile right? I'm trying to build a mobile application and include this external javascript file in it.

Is it possible to do so? And if so, how would we go about it?

You can use:

class Widget extends React.Component {
    uploadWidget = () => {      
        cloudinary.openUploadWidget({ cloud_name: "<cloud_name>", upload_preset: "<upload_preset>", sources:['local','url','facebook','dropbox', 'google_photos'], folder: "test"}, 
            function(error, result){ 
                console.log(error);
        });         
    }
  render() {
    return(
    <div>
      <div>Please update your cloudname and upload preset</div>
      <input type="button" value="click me" onClick={this.uploadWidget}/>
    </div>
    );
  }
}

ReactDOM.render(
  <Widget/>,
  document.getElementById('container')
);

http://jsfiddle.net/RayStra/gevc4ktm/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM