@exodus/react-native-webview 11.26.1-exodus.6 → 11.26.1-exodus.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/.all-contributorsrc +185 -0
  2. package/.circleci/config.yml +66 -0
  3. package/.eslintignore +2 -0
  4. package/.eslintrc.js +94 -0
  5. package/.flowconfig +88 -0
  6. package/.flowconfig.android +88 -0
  7. package/.gitattributes +12 -0
  8. package/.github/CODEOWNERS +1 -0
  9. package/.github/ISSUE_TEMPLATE/bug-report.md +42 -0
  10. package/.github/ISSUE_TEMPLATE/feature_request.md +30 -0
  11. package/.github/workflows/android-ci.yml +35 -0
  12. package/.github/workflows/detox.yml +20 -0
  13. package/.github/workflows/ios-ci.yml +31 -0
  14. package/.github/workflows/scripts/install-vs-features.ps1 +108 -0
  15. package/.github/workflows/stale.yml +17 -0
  16. package/.gitignore +62 -0
  17. package/.prettierrc.js +10 -0
  18. package/.releaserc +15 -0
  19. package/.vscode/settings.json +9 -0
  20. package/android/.gradle/7.4.2/checksums/checksums.lock +0 -0
  21. package/android/.gradle/7.4.2/dependencies-accessors/dependencies-accessors.lock +0 -0
  22. package/android/.gradle/7.4.2/dependencies-accessors/gc.properties +0 -0
  23. package/android/.gradle/7.4.2/executionHistory/executionHistory.lock +0 -0
  24. package/android/.gradle/7.4.2/fileChanges/last-build.bin +0 -0
  25. package/android/.gradle/7.4.2/fileHashes/fileHashes.lock +0 -0
  26. package/android/.gradle/7.4.2/gc.properties +0 -0
  27. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  28. package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
  29. package/android/.gradle/vcs-1/gc.properties +0 -0
  30. package/babel.config.js +11 -0
  31. package/bin/setup +26 -0
  32. package/docs/Contributing.md +102 -0
  33. package/docs/Custom-Android.md +222 -0
  34. package/docs/Custom-iOS.md +236 -0
  35. package/docs/Debugging.md +101 -0
  36. package/docs/Getting-Started.md +142 -0
  37. package/docs/Guide.md +613 -0
  38. package/docs/Reference.md +1629 -0
  39. package/example/.gitignore +14 -0
  40. package/example/.watchmanconfig +1 -0
  41. package/example/App.tsx +262 -0
  42. package/example/android/.gradle/7.3.3/checksums/checksums.lock +0 -0
  43. package/example/android/.gradle/7.3.3/checksums/md5-checksums.bin +0 -0
  44. package/example/android/.gradle/7.3.3/checksums/sha1-checksums.bin +0 -0
  45. package/example/android/.gradle/7.3.3/dependencies-accessors/dependencies-accessors.lock +0 -0
  46. package/example/android/.gradle/7.3.3/dependencies-accessors/gc.properties +0 -0
  47. package/example/android/.gradle/7.3.3/fileChanges/last-build.bin +0 -0
  48. package/example/android/.gradle/7.3.3/fileHashes/fileHashes.lock +0 -0
  49. package/example/android/.gradle/7.3.3/gc.properties +0 -0
  50. package/example/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  51. package/example/android/.gradle/buildOutputCleanup/cache.properties +2 -0
  52. package/example/android/.gradle/vcs-1/gc.properties +0 -0
  53. package/example/android/build.gradle +15 -0
  54. package/example/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  55. package/example/android/gradle/wrapper/gradle-wrapper.properties +5 -0
  56. package/example/android/gradle.properties +34 -0
  57. package/example/android/gradlew +234 -0
  58. package/example/android/gradlew.bat +89 -0
  59. package/example/android/settings.gradle +12 -0
  60. package/example/app.json +20 -0
  61. package/example/assets/test.html +9 -0
  62. package/example/babel.config.js +3 -0
  63. package/example/examples/Alerts.tsx +72 -0
  64. package/example/examples/ApplePay.tsx +23 -0
  65. package/example/examples/Background.tsx +54 -0
  66. package/example/examples/Downloads.tsx +57 -0
  67. package/example/examples/Injection.tsx +161 -0
  68. package/example/examples/LocalPageLoad.tsx +16 -0
  69. package/example/examples/Messaging.tsx +63 -0
  70. package/example/examples/NativeWebpage.tsx +22 -0
  71. package/example/examples/Scrolling.tsx +68 -0
  72. package/example/examples/Uploads.tsx +69 -0
  73. package/example/index.js +9 -0
  74. package/example/ios/Podfile +8 -0
  75. package/example/ios/Podfile.lock +445 -0
  76. package/ios/Podfile +10 -0
  77. package/ios/Podfile.lock +3 -0
  78. package/ios/Pods/Manifest.lock +3 -0
  79. package/ios/Pods/Pods.xcodeproj/project.pbxproj +397 -0
  80. package/ios/Pods/Pods.xcodeproj/xcuserdata/gabrielezenwankwo.xcuserdatad/xcschemes/Pods-RNCWebView.xcscheme +58 -0
  81. package/ios/Pods/Pods.xcodeproj/xcuserdata/gabrielezenwankwo.xcuserdatad/xcschemes/xcschememanagement.plist +16 -0
  82. package/ios/Pods/Target Support Files/Pods-RNCWebView/Pods-RNCWebView-Info.plist +26 -0
  83. package/ios/Pods/Target Support Files/Pods-RNCWebView/Pods-RNCWebView-acknowledgements.markdown +3 -0
  84. package/ios/Pods/Target Support Files/Pods-RNCWebView/Pods-RNCWebView-acknowledgements.plist +29 -0
  85. package/ios/Pods/Target Support Files/Pods-RNCWebView/Pods-RNCWebView-dummy.m +5 -0
  86. package/ios/Pods/Target Support Files/Pods-RNCWebView/Pods-RNCWebView-umbrella.h +16 -0
  87. package/ios/Pods/Target Support Files/Pods-RNCWebView/Pods-RNCWebView.debug.xcconfig +8 -0
  88. package/ios/Pods/Target Support Files/Pods-RNCWebView/Pods-RNCWebView.modulemap +6 -0
  89. package/ios/Pods/Target Support Files/Pods-RNCWebView/Pods-RNCWebView.release.xcconfig +8 -0
  90. package/ios/RNCWebView.xcworkspace/contents.xcworkspacedata +32 -0
  91. package/jest-setups/jest.setup.js +8 -0
  92. package/jest.config.js +184 -0
  93. package/lib/UpdateOS.d.ts +6 -0
  94. package/lib/UpdateOS.d.ts.map +1 -0
  95. package/lib/UpdateOS.js +49 -0
  96. package/lib/WebView.android.d.ts.map +1 -0
  97. package/lib/WebView.android.js +4 -1
  98. package/lib/WebView.d.ts.map +1 -0
  99. package/lib/WebView.ios.d.ts.map +1 -0
  100. package/lib/WebView.ios.js +5 -2
  101. package/lib/WebView.styles.d.ts.map +1 -0
  102. package/lib/WebViewNativeComponent.android.d.ts.map +1 -0
  103. package/lib/WebViewNativeComponent.ios.d.ts.map +1 -0
  104. package/lib/WebViewShared.d.ts.map +1 -0
  105. package/lib/WebViewTypes.d.ts +5 -1
  106. package/lib/WebViewTypes.d.ts.map +1 -0
  107. package/lib/index.d.ts.map +1 -0
  108. package/metro.config.js +57 -0
  109. package/package.json +1 -1
  110. package/src/WebView.android.tsx +246 -0
  111. package/src/WebView.ios.tsx +221 -0
  112. package/src/WebView.styles.ts +44 -0
  113. package/src/WebView.tsx +18 -0
  114. package/src/WebViewNativeComponent.android.ts +8 -0
  115. package/src/WebViewNativeComponent.ios.ts +8 -0
  116. package/src/WebViewShared.tsx +257 -0
  117. package/src/WebViewTypes.ts +914 -0
  118. package/src/__tests__/WebViewShared-test.js +208 -0
  119. package/src/__tests__/__snapshots__/WebViewShared-test.js.snap +8 -0
  120. package/src/index.ts +4 -0
  121. package/tsconfig.json +24 -0
  122. package/yarn.lock +13895 -0
@@ -0,0 +1,236 @@
1
+ **NOTE: This document was imported from [the original WebView documentation](https://github.com/facebook/react-native-website/blob/7d3e9e120e38a7ba928f6b173eb98f88b6f2f85f/docs/custom-webview-ios.md). While it may prove useful, it has not been adapted to React Native WebView yet.**
2
+
3
+ While the built-in web view has a lot of features, it is not possible to handle every use-case in React Native. You can, however, extend the web view with native code without forking React Native or duplicating all the existing web view code.
4
+
5
+ Before you do this, you should be familiar with the concepts in [native UI components](native-components-ios). You should also familiarise yourself with the [native code for web views](https://github.com/react-native-webview/react-native-webview/blob/master/apple/RNCWebViewManager.m), as you will have to use this as a reference when implementing new features—although a deep understanding is not required.
6
+
7
+ ## Native Code
8
+
9
+ Like for regular native components, you need a view manager and an web view.
10
+
11
+ For the view, you'll need to make a subclass of `RCTWebView`.
12
+
13
+ ```objc
14
+ // RCTCustomWebView.h
15
+ #import <React/RCTWebView.h>
16
+
17
+ @interface RCTCustomWebView : RCTWebView
18
+
19
+ @end
20
+
21
+ // RCTCustomWebView.m
22
+ #import "RCTCustomWebView.h"
23
+
24
+ @interface RCTCustomWebView ()
25
+
26
+ @end
27
+
28
+ @implementation RCTCustomWebView { }
29
+
30
+ @end
31
+ ```
32
+
33
+ For the view manager, you need to make a subclass `RCTWebViewManager`. You must still include:
34
+
35
+ * `(UIView *)view` that returns your custom view
36
+ * The `RCT_EXPORT_MODULE()` tag
37
+
38
+ ```objc
39
+ // RCTCustomWebViewManager.h
40
+ #import <React/RCTWebViewManager.h>
41
+
42
+ @interface RCTCustomWebViewManager : RCTWebViewManager
43
+
44
+ @end
45
+
46
+ // RCTCustomWebViewManager.m
47
+ #import "RCTCustomWebViewManager.h"
48
+ #import "RCTCustomWebView.h"
49
+
50
+ @interface RCTCustomWebViewManager () <RCTWebViewDelegate>
51
+
52
+ @end
53
+
54
+ @implementation RCTCustomWebViewManager { }
55
+
56
+ RCT_EXPORT_MODULE()
57
+
58
+ - (UIView *)view
59
+ {
60
+ RCTCustomWebView *webView = [RCTCustomWebView new];
61
+ webView.delegate = self;
62
+ return webView;
63
+ }
64
+
65
+ @end
66
+ ```
67
+
68
+ ### Adding New Events and Properties
69
+
70
+ Adding new properties and events is the same as regular UI components. For properties, you define an `@property` in the header. For events, you define a `RCTDirectEventBlock` in the view's `@interface`.
71
+
72
+ ```objc
73
+ // RCTCustomWebView.h
74
+ @property (nonatomic, copy) NSString *finalUrl;
75
+
76
+ // RCTCustomWebView.m
77
+ @interface RCTCustomWebView ()
78
+
79
+ @property (nonatomic, copy) RCTDirectEventBlock onNavigationCompleted;
80
+
81
+ @end
82
+ ```
83
+
84
+ Then expose it in the view manager's `@implementation`.
85
+
86
+ ```objc
87
+ // RCTCustomWebViewManager.m
88
+ RCT_EXPORT_VIEW_PROPERTY(onNavigationCompleted, RCTDirectEventBlock)
89
+ RCT_EXPORT_VIEW_PROPERTY(finalUrl, NSString)
90
+ ```
91
+
92
+ ### Extending Existing Events
93
+
94
+ You should refer to [RCTWebView.m](https://github.com/facebook/react-native/blob/master/React/Views/RCTWebView.m) in the React Native codebase to see what handlers are available and how they are implemented. You can extend any methods here to provide extra functionality.
95
+
96
+ By default, most methods aren't exposed from RCTWebView. If you need to expose them, you need to create an [Objective C category](https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/CustomizingExistingClasses/CustomizingExistingClasses.html), and then expose all the methods you need to use.
97
+
98
+ ```objc
99
+ // RCTWebView+Custom.h
100
+ #import <React/RCTWebView.h>
101
+
102
+ @interface RCTWebView (Custom)
103
+ - (BOOL)webView:(__unused UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType;
104
+ - (NSMutableDictionary<NSString *, id> *)baseEvent;
105
+ @end
106
+ ```
107
+
108
+ Once these are exposed, you can reference them in your custom web view class.
109
+
110
+ ```objc
111
+ // RCTCustomWebView.m
112
+
113
+ // Remember to import the category file.
114
+ #import "RCTWebView+Custom.h"
115
+
116
+ - (BOOL)webView:(__unused UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request
117
+ navigationType:(UIWebViewNavigationType)navigationType
118
+ {
119
+ BOOL allowed = [super webView:webView shouldStartLoadWithRequest:request navigationType:navigationType];
120
+
121
+ if (allowed) {
122
+ NSString* url = request.URL.absoluteString;
123
+ if (url && [url isEqualToString:_finalUrl]) {
124
+ if (_onNavigationCompleted) {
125
+ NSMutableDictionary<NSString *, id> *event = [self baseEvent];
126
+ _onNavigationCompleted(event);
127
+ }
128
+ }
129
+ }
130
+
131
+ return allowed;
132
+ }
133
+ ```
134
+
135
+ ### Setting Client Certificate Authentication Credential
136
+
137
+ If you open webpages that needs a Client Certificate for Authentication, you can create a credential and pass it to the webview:
138
+
139
+ ```
140
+ [RNCWebView setClientAuthenticationCredential:credential];
141
+ ```
142
+
143
+ This can be paired with a call from Javascript to pass a string label for the certificate stored in keychain and use native calls to fetch the certificate to create a credential object. This call can be made anywhere that makes sense for your application (e.g. as part of the user authentication stack). The only requirement is to make this call before displaying any webviews.
144
+
145
+ ### Allowing custom CAs (Certifica Authorities) and enabling SSL Pinning
146
+
147
+ If you need to connect to a server which has a self signed certificate, or want to perform SSL Pinning on the webview requests, you need to pass a dictionary with the host as the key, and the certificate as the value of each item:
148
+
149
+
150
+ ```objc
151
+ -(void)installCerts {
152
+
153
+ // Get the bundle where the certificates in DER format are present.
154
+ NSBundle *bundle = [NSBundle mainBundle];
155
+
156
+ NSMutableDictionary* certMap = [NSMutableDictionary new];
157
+
158
+ NSData *rootCertData = [NSData dataWithContentsOfFile:[bundle pathForResource:@"example_ca" ofType:@"der"]];
159
+
160
+ SecCertificateRef certificate = SecCertificateCreateWithData(NULL, (CFDataRef) rootCertData);
161
+
162
+ OSStatus err = SecItemAdd((CFDictionaryRef) [NSDictionary dictionaryWithObjectsAndKeys:(id) kSecClassCertificate, kSecClass, certificate, kSecValueRef, nil], NULL);
163
+
164
+ [certMap setObject:(__bridge id _Nonnull)(certificate) forKey:@"example.com"];
165
+
166
+ [RNCWebView setCustomCertificatesForHost:certMap];
167
+ }
168
+
169
+ ```
170
+
171
+ Multiple hosts can be added to the dictionary, and only one certificate for a host is allowed. The verification will succeed if any of the certificates in the chain of the request matches the one defined for the request's host.
172
+
173
+
174
+ ## JavaScript Interface
175
+
176
+ To use your custom web view, you may want to create a class for it. Your class must return a `WebView` component with the prop `nativeConfig.component` set to your native component (see below).
177
+
178
+ To get your native component, you must use `requireNativeComponent`: the same as for regular custom components.
179
+
180
+ ```javascript
181
+ import React, {Component} from 'react';
182
+ import {WebView, requireNativeComponent, NativeModules} from 'react-native';
183
+ const {CustomWebViewManager} = NativeModules;
184
+
185
+ export default class CustomWebView extends Component {
186
+ render() {
187
+ return (
188
+ <WebView
189
+ {...this.props}
190
+ nativeConfig={{
191
+ component: RCTCustomWebView,
192
+ viewManager: CustomWebViewManager,
193
+ }}
194
+ />
195
+ );
196
+ }
197
+ }
198
+
199
+ const RCTCustomWebView = requireNativeComponent('RCTCustomWebView');
200
+ ```
201
+
202
+ If you want to add custom props to your native component, you can use `nativeConfig.props` on the web view. For iOS, you should also set the `nativeConfig.viewManager` prop with your custom WebView ViewManager as in the example above.
203
+
204
+ For events, the event handler must always be set to a function. This means it isn't safe to use the event handler directly from `this.props`, as the user might not have provided one. The standard approach is to create a event handler in your class, and then invoking the event handler given in `this.props` if it exists.
205
+
206
+ If you are unsure how something should be implemented from the JS side, look at [WebView.ios.tsx](https://github.com/react-native-webview/react-native-webview/blob/master/src/WebView.ios.tsx) in the React Native WebView source.
207
+
208
+ ```javascript
209
+ export default class CustomWebView extends Component {
210
+ _onNavigationCompleted = (event) => {
211
+ const {onNavigationCompleted} = this.props;
212
+ onNavigationCompleted && onNavigationCompleted(event);
213
+ };
214
+
215
+ render() {
216
+ return (
217
+ <WebView
218
+ {...this.props}
219
+ nativeConfig={{
220
+ component: RCTCustomWebView,
221
+ props: {
222
+ finalUrl: this.props.finalUrl,
223
+ onNavigationCompleted: this._onNavigationCompleted,
224
+ },
225
+ viewManager: CustomWebViewManager,
226
+ }}
227
+ />
228
+ );
229
+ }
230
+ }
231
+ ```
232
+ ## Translations
233
+
234
+ This file is available at:
235
+
236
+ - [Brazilian portuguese](Custom-iOS.portuguese.md)
@@ -0,0 +1,101 @@
1
+ # React Native WebView Debugging Guide
2
+
3
+ Here are some helpful React Native WebView debugging tips.
4
+
5
+ ## Script Errors
6
+
7
+ It can be difficult to debug syntax errors and other script errors in WebView, since errors don't show up in a console by default.
8
+
9
+ One option (if you're loading HTML from an external source) is to inject an error handler before the content is loaded.
10
+
11
+ ```js
12
+ <WebView
13
+ injectedJavaScriptBeforeContentLoaded={`
14
+ window.onerror = function(message, sourcefile, lineno, colno, error) {
15
+ alert("Message: " + message + " - Source: " + sourcefile + " Line: " + lineno + ":" + colno);
16
+ return true;
17
+ };
18
+ true;
19
+ `}
20
+ source={{
21
+ uri:
22
+ 'https://bl.ocks.org/jamonholmgren/raw/48423fd99537283beace1daa2688e80f/',
23
+ }}
24
+ />
25
+ ```
26
+
27
+ This will provide an Alert box with (hopefully) useful debugging information.
28
+
29
+ If you're injecting JavaScript, this may fail with `Script error` and no other useful information. One simple way to debug this is to wrap your injected JavaScript in a try/catch, like so:
30
+
31
+ ```js
32
+ const js = `
33
+ try {
34
+ // your code here
35
+ } catch(e) {
36
+ alert(e)
37
+ }
38
+ true;
39
+ `;
40
+ ```
41
+
42
+ This will bring up an alert with the error message, which may or may not be helpful.
43
+
44
+ If these two simple methods fail to uncover the bug, try using the next technique!
45
+
46
+ ## Debugging WebView Contents
47
+
48
+ ### iOS & Safari
49
+
50
+ It's possible to debug WebView contents in the iOS simulator or on a device using Safari Developer Toolkit.
51
+
52
+ #### Steps:
53
+
54
+ 1. Open Safari Preferences -> "Advanced" tab -> enable checkbox "Show Develop menu in menu bar"
55
+ 2. Start app with React Native WebView in iOS simulator or iOS device
56
+ 3. Safari -> Develop -> [device name] -> [app name] -> [url - title]
57
+ 4. You can now debug the WebView contents just as you would on the web
58
+
59
+ ##### Notes:
60
+
61
+ When debugging on device you must enable Web Inspector in your device settings:
62
+
63
+ Settings -> Safari -> Advanced -> Web Inspector
64
+
65
+ Also, if you don't see your device in the Develop menu, and you started Safari before you started your simulator, try restarting Safari.
66
+
67
+ ### Android & Chrome
68
+
69
+ It's possible to debug WebView contents in the Android emulator or on a device using Chrome DevTools.
70
+
71
+ 1. You will need to make the following change to `MainApplication.java` to enabled web contents debugging:
72
+
73
+ ```java
74
+ import android.webkit.WebView;
75
+
76
+ @Override
77
+ public void onCreate() {
78
+ super.onCreate();
79
+ ...
80
+ WebView.setWebContentsDebuggingEnabled(true);
81
+ }
82
+ ```
83
+
84
+ 2. Start app with React Native WebView in Android emulator or Android device
85
+ 3. Open `chrome://inspect/#devices` on Chrome (Reference: [Remote debug Android devices](https://developer.chrome.com/docs/devtools/remote-debugging/))
86
+ 4. Select your device on the left and select "Inspect" on the WebView contents you'd like to inspect
87
+ 5. You can now debug the WebView contents just as you would on the web
88
+
89
+ ![image](https://user-images.githubusercontent.com/1479215/47129785-9476e480-d24b-11e8-8cb1-fba77ee1c072.png)
90
+
91
+ ##### Note:
92
+
93
+ When debugging on device you must enable USB debugging in your device settings:
94
+
95
+ Settings -> System -> About Phone -> Developer options -> enable USB debugging
96
+
97
+ ## Translations
98
+
99
+ This file is available at:
100
+
101
+ - [Brazilian portuguese](Debugging.portuguese.md)
@@ -0,0 +1,142 @@
1
+ # React Native WebView Getting Started Guide
2
+
3
+ Here's how to get started quickly with the React Native WebView.
4
+
5
+ ## 1. Add react-native-webview to your dependencies
6
+
7
+ ```
8
+ $ yarn add react-native-webview
9
+ ```
10
+
11
+ (or)
12
+
13
+ For npm use
14
+
15
+ ```
16
+ $ npm install --save react-native-webview
17
+ ```
18
+
19
+ ## 2. Link native dependencies
20
+
21
+ From react-native 0.60 autolinking will take care of the link step but don't forget to run `pod install`
22
+
23
+ React Native modules that include native Objective-C, Swift, Java, or Kotlin code have to be "linked" so that the compiler knows to include them in the app.
24
+
25
+ ```
26
+ $ react-native link react-native-webview
27
+ ```
28
+
29
+ _NOTE: If you ever need to uninstall React Native WebView, run `react-native unlink react-native-webview` to unlink it._
30
+
31
+ ### iOS & macOS:
32
+
33
+ If using CocoaPods, in the `ios/` or `macos/` directory run:
34
+
35
+ ```
36
+ $ pod install
37
+ ```
38
+
39
+ While you can manually link the old way using [react-native own tutorial](https://reactnative.dev/docs/linking-libraries-ios), we find it easier to use CocoaPods.
40
+ If you wish to use CocoaPods and haven't set it up yet, please instead refer to [that article](https://engineering.brigad.co/demystifying-react-native-modules-linking-ae6c017a6b4a).
41
+
42
+ ### Android:
43
+
44
+ Android - react-native-webview version <6:
45
+ This module does not require any extra step after running the link command 🎉
46
+
47
+ Android - react-native-webview version >=6.X.X:
48
+ Please make sure AndroidX is enabled in your project by editting `android/gradle.properties` and adding 2 lines:
49
+
50
+ ```
51
+ android.useAndroidX=true
52
+ android.enableJetifier=true
53
+ ```
54
+
55
+ For Android manual installation, please refer to [this article](https://engineering.brigad.co/demystifying-react-native-modules-linking-964399ec731b) where you can find detailed step on how to link any react-native project.
56
+
57
+ ### Windows:
58
+
59
+ Autolinking is supported for React Native Windows v0.63 and higher. If your app uses a React Native Windows version that does not have autolinking support, make the following additions to the given files manually:
60
+
61
+ #### **windows/myapp.sln**
62
+
63
+ Add the `ReactNativeWebView` project to your solution.
64
+
65
+ 1. Open the solution in Visual Studio 2019
66
+ 2. Right-click Solution icon in Solution Explorer > Add > Existing Project
67
+ Select `node_modules\react-native-webview\windows\ReactNativeWebView\ReactNativeWebView.vcxproj`
68
+
69
+ #### **windows/myapp/myapp.vcxproj**
70
+
71
+ Add a reference to `ReactNativeWebView` to your main application project. From Visual Studio 2019:
72
+
73
+ 1. Right-click main application project > Add > Reference...
74
+ Check `ReactNativeWebView` from Solution Projects.
75
+
76
+ 2. Modify files below to add the package providers to your main application project
77
+
78
+ #### **pch.h**
79
+
80
+ Add `#include "winrt/ReactNativeWebView.h"`.
81
+
82
+ #### **app.cpp**
83
+
84
+ Add `PackageProviders().Append(winrt::ReactNativeWebView::ReactPackageProvider());` before `InitializeComponent();`.
85
+
86
+ Note if you want to enable scroll with Touch for the WebView component you must disable perspective for your app using [ReactRootView.IsPerspectiveEnabled](https://microsoft.github.io/react-native-windows/docs/ReactRootView#isperspectiveenabled).
87
+
88
+ ## 3. WebView2 Support
89
+ The WebView2 control is a [WinUI](https://docs.microsoft.com/windows/apps/winui/) control that renders web content using the Microsoft Edge (Chromium) rendering engine. We have added support for the WebView2 control to the react-native-webview community module in v11.18.0.
90
+ If your app is RNW v0.68 or higher, follow these steps:
91
+
92
+ i. Let autolinking handle adding the `ReactNativeWebView` project to your app.
93
+
94
+ ii. Customize your app's WinUI 2.x version to version 2.8.0-prerelease.210927001 or higher. See [here](https://microsoft.github.io/react-native-windows/docs/customizing-sdk-versions) for instructions. The WinUI 2.x support for WebView2 is not yet available in "stable" releases, so for now you will need to use a prerelease version.
95
+
96
+ iii. You may need to specify the `Microsoft.Web.WebView2` package in your app's `packages.config` file. If this is needed, you will get a build error listing the version of the package that you needed to specify. Simply add the package to your `packages.config`, and you should be good to go.
97
+
98
+ Now you can access the WinUI WebView2 control from your app's JavaScript via the `useWebView2` prop.
99
+
100
+ ## 4. Import the webview into your component
101
+
102
+ ```js
103
+ import React, { Component } from 'react';
104
+ import { WebView } from 'react-native-webview';
105
+
106
+ class MyWeb extends Component {
107
+ render() {
108
+ return (
109
+ <WebView
110
+ source={{ uri: 'https://infinite.red' }}
111
+ style={{ marginTop: 20 }}
112
+ />
113
+ );
114
+ }
115
+ }
116
+ ```
117
+
118
+ Minimal example with inline HTML:
119
+
120
+ ```js
121
+ import React, { Component } from 'react';
122
+ import { WebView } from 'react-native-webview';
123
+
124
+ class MyInlineWeb extends Component {
125
+ render() {
126
+ return (
127
+ <WebView
128
+ originWhitelist={['*']}
129
+ source={{ html: '<h1>Hello world</h1>' }}
130
+ />
131
+ );
132
+ }
133
+ }
134
+ ```
135
+
136
+ Next, check out the [API Reference](Reference.md) or [In-Depth Guide](Guide.md).
137
+
138
+ ## Translations
139
+
140
+ This file is available at:
141
+
142
+ - [Brazilian portuguese](Getting-Started.portuguese.md)