react-native-webview-with-refresh
Getting started
$ npm install react-native-webview-with-refresh --save
Mostly automatic installation
$ react-native link react-native-webview-with-refresh
Manual installation
iOS
- In XCode, in the project navigator, right click
Libraries
➜Add Files to [your project's name]
- Go to
node_modules
➜react-native-webview-with-refresh
and addRNWebviewWithRefresh.xcodeproj
- In XCode, in the project navigator, select your project. Add
libRNWebviewWithRefresh.a
to your project'sBuild Phases
➜Link Binary With Libraries
- Run your project (
Cmd+R
)<
Android
- Open up
android/app/src/main/java/[...]/MainActivity.java
- Add
import com.reactlibrary.RNWebviewWithRefreshPackage;
to the imports at the top of the file - Add
new RNWebviewWithRefreshPackage()
to the list returned by thegetPackages()
method
-
Append the following lines to
android/settings.gradle
:include ':react-native-webview-with-refresh' project(':react-native-webview-with-refresh').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-webview-with-refresh/android')
-
Insert the following lines inside the dependencies block in
android/app/build.gradle
:compile project(':react-native-webview-with-refresh')
Parameters
Parameter | Usage |
---|---|
url | the url loaded |
matchCondition | regex; would call onUrlMatch if the url meet this condition |
onUrlMatch | the callback when the url meet the condition |
onStartLoad | the callback when the url start to load |
OnFinishLoad | the callback when the url loading is committed |
Usage
; { ; ; }; { console; }; { console; }; { return <View style=stylescontainer> <WebViewWithRefresh url="https://www.google.com/" matchCondition="(http|https)://starfans.info" onUrlMatch=thisonUrlChange onStartLoad=thisonStartLoad onFinishLoad=thisonFinishLoad style=styleswebview ref="webview" /> </View> ; }
Warnning
For iOS, this lib accept all SSL cert as the WKWebview seems being rude to https://google.com/
ChangeLog
1.1 switch to WKWebview for better performance; add onStartLoad and onFinishLoad callbacks.