react-native-webkit-webview
Forked from react-native-webview-crosswalk
Cross-platform Webview component,With better performance on android.
Npm scripts sucks.Yarn recommended
Dependencies
react-native >=0.32.0
, react >= 15.3.0
Installation
- From the root of your React Native project
npm install react-native-webkit-webview --savemkdir android/app/libscp node_modules/react-native-webkit-webview/libs/xwalk_core_library-22.52.561.4.aar android/app/libs/
Include module in your Android project
- In
android/setting.gradle
...+ include ':CrosswalkWebView', ':app'+ project(':CrosswalkWebView').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-webkit-webview')
Include libs in your Android project
- In
android/build.gradle
...allprojects { repositories { mavenLocal() jcenter() + flatDir {+ dirs 'libs'+ } }}
- In
android/app/build.gradle
...dependencies { ...+ compile (name: "xwalk_core_library-22.52.561.4", ext: "aar")+ compile project(':CrosswalkWebView')}
-
Register package :
-
In
android/app/src/main/java/com/YOUR_PROJECT_NAME/MainActivity.java
+ import com.jordansexton.react.crosswalk.webview.CrosswalkWebViewPackage; public class MainApplication extends Application implements ReactApplication { ...... @Override protected List<ReactPackage> getPackages() { return Arrays.<ReactPackage>asList( new MainReactPackage(),+ new CrosswalkWebViewPackage() // <--- add this line ); } ...... }
Usage
// DemoComponents.js { return <View> <TouchableHighlight onPress= thispassMessageToWebpage > <Text>Tell webpage some message</Text> </TouchableHighlight> <WebkitView source= localDemoPage // local file usage} source= uri:'http://www.demo.com/path' //link usage }} injectedJavascript="setTimeout(function(){document.write('WONDERFUL')},1000)" onMessage = thismessageHandler ref= { thiswebkitView = webkitView } /> </View> ) { thiswebkitView } { console }
<!-- demoPage.html --> Document
License
MIT