You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/fabric-native-components-android.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -187,7 +187,7 @@ The `ReactWebView` extends the Android `WebView` so you can reuse all the proper
187
187
188
188
The class defines the three Android constructors but defers their actual implementation to the private `configureComponent` function. This function takes care of initializing all the components specific properties: in this case you are setting the layout of the `WebView` and you are defining the `WebClient` that you use to customize the behavior of the `WebView`. In this code, the `ReactWebView` emits an event when the page finishes loading, by implementing the `WebClient`'s `onPageFinished` method.
189
189
190
-
The code then define an helper function to actually emit an event. To emit an event, you have to:
190
+
The code then defines a helper function to actually emit an event. To emit an event, you have to:
191
191
192
192
- grab a reference to the `ReactContext`;
193
193
- retrieve the `surfaceId` of the view that you are presenting;
@@ -327,7 +327,7 @@ class ReactWebViewManager(context: ReactApplicationContext) : SimpleViewManager<
327
327
</TabItem>
328
328
</Tabs>
329
329
330
-
The `ReactWebViewManager` extends the `SimpleViewManager` class from react and implements the `CustomWebViewManagerInterface`, generated by Codegen.
330
+
The `ReactWebViewManager` extends the `SimpleViewManager` class from React and implements the `CustomWebViewManagerInterface`, generated by Codegen.
331
331
332
332
It holds a reference of the `CustomWebViewManagerDelegate`, another element generated by Codegen.
333
333
@@ -341,7 +341,7 @@ Finally, if the component can emit an event, you need to map the event name by o
341
341
342
342
### 4. Write the `ReactWebViewPackage`
343
343
344
-
As you do with Native Modules, also Native Components needs to implement the `ReactPackage` class. This is an object that you can use to register the component in the React Native runtime.
344
+
As you do with Native Modules, Native Components also need to implement the `ReactPackage` class. This is an object that you can use to register the component in the React Native runtime.
Copy file name to clipboardExpand all lines: docs/fabric-native-components-ios.md
+9-9Lines changed: 9 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,7 +18,7 @@ You can [manually run](the-new-architecture/codegen-cli) the Codegen, however it
18
18
```bash
19
19
cd ios
20
20
bundle install
21
-
bundle execpods install
21
+
bundle execpod install
22
22
```
23
23
24
24
Importantly you will see logging output from Codegen, which we're going to use in Xcode to build our WebView native component.
@@ -193,11 +193,11 @@ This code is written in Objective-C++ and contains various details:
193
193
194
194
- the `@interface` implements two protocols:
195
195
- `RCTCustomWebViewViewProtocol`, generated by Codegen;
196
-
- `WKNavigationDelegate`, provided by the WebKit frameworks to handle the web view navigation events;
197
-
- the `init` method that instantiate the `WKWebView`, adds it to the subviews and that set the `navigationDelegate`;
196
+
- `WKNavigationDelegate`, provided by the WebKit framework to handle the web view navigation events;
197
+
- the `init` method that instantiates the `WKWebView`, adds it to the subviews and that sets the `navigationDelegate`;
198
198
- the `updateProps` method that is called by React Native when the component's props change;
199
-
- the `layoutSubviews` method that describe how the custom view needs to be laid out;
200
-
- the `webView:didFinishNavigation:` method that let you handle the what do when the `WKWebView` finishes loading the page;
199
+
- the `layoutSubviews` method that describes how the custom view needs to be laid out;
200
+
- the `webView:didFinishNavigation:` method that lets you handle what to do when the `WKWebView` finishes loading the page;
201
201
- the `urlIsValid:(std::string)propString` method that checks whether the URL received as prop is valid;
202
202
- the `eventEmitter` method which is a utility to retrieve a strongly typed `eventEmitter` instance
203
203
- the `componentDescriptorProvider` which returns the `ComponentDescriptor` generated by Codegen;
@@ -212,10 +212,10 @@ Update the `AppDelegate.mm` to make your application aware of our custom WebView
212
212
#import "AppDelegate.h"
213
213
214
214
#import <React/RCTBundleURLProvider.h>
215
+
// highlight-start
215
216
#import <React/RCTBridge+Private.h>
216
-
// highlight-next-line
217
217
#import "RCTWebView.h"
218
-
218
+
// highlight-end
219
219
@implementation AppDelegate
220
220
// ...
221
221
// highlight-start
@@ -230,9 +230,9 @@ Update the `AppDelegate.mm` to make your application aware of our custom WebView
230
230
@end
231
231
```
232
232
233
-
This code override the `thirdPartyFabricComponents` method by obtainig a mutable copy of the dictionary of third party's components coming from other sources, like third party libraries.
233
+
This code overrides the `thirdPartyFabricComponents` method by obtaining a mutable copy of the dictionary of third party components coming from other sources, like third party libraries.
234
234
235
-
It then adds an entry to the dictionary with the name used in the Codegen specification file. In this way, when React requires to load a component with name `CustomWebView`, React Native will instantiate a `RCTWebView`.
235
+
It then adds an entry to the dictionary with the name used in the Codegen specification file. In this way, when React is required to load a component with name `CustomWebView`, React Native will instantiate a `RCTWebView`.
Copy file name to clipboardExpand all lines: docs/fabric-native-components.md
+8-7Lines changed: 8 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,9 +10,9 @@ import {FabricNativeComponentsAndroid,FabricNativeComponentsIOS} from './\_fabri
10
10
11
11
# Native Components
12
12
13
-
If you want to build _new_ React Native Components that wraps around a [Host Component](https://reactnative.dev/architecture/glossary#host-view-tree-and-host-view) like a unique kind of [CheckBox](https://developer.android.com/reference/androidx/appcompat/widget/AppCompatCheckBox) on Android, or a [UIButton](https://developer.apple.com/documentation/uikit/uibutton?language=objc) on iOS, you should use a Fabric Native Component.
13
+
If you want to build _new_ React Native Components that wrap around a [Host Component](https://reactnative.dev/architecture/glossary#host-view-tree-and-host-view) like a unique kind of [CheckBox](https://developer.android.com/reference/androidx/appcompat/widget/AppCompatCheckBox) on Android, or a [UIButton](https://developer.apple.com/documentation/uikit/uibutton?language=objc) on iOS, you should use a Fabric Native Component.
14
14
15
-
This guide will show you how to build Fabric Native Component, by implementing a web view component. The steps to doing this are:
15
+
This guide will show you how to build Fabric Native Components, by implementing a web view component. The steps to doing this are:
16
16
17
17
1. Define a JavaScript specification using Flow or TypeScript.
18
18
2. Configure the dependencies management system to generate code from the provided spec and to be auto-linked.
This guide will show you how to create a Web View component. We will be creating the component by using the Android's [`WebView`](https://developer.android.com/reference/android/webkit/WebView) component, and the iOS'[`WKWebView`](https://developer.apple.com/documentation/webkit/wkwebview?language=objc) component.
30
+
This guide will show you how to create a Web View component. We will be creating the component by using the Android's [`WebView`](https://developer.android.com/reference/android/webkit/WebView) component, and the iOS [`WKWebView`](https://developer.apple.com/documentation/webkit/wkwebview?language=objc) component.
31
31
32
32
Let's start by creating the folders structure to hold our component's code:
33
33
@@ -101,6 +101,7 @@ type NativeProps = $ReadOnly<{|
This specification is composed of three main parts, exluding the imports:
110
111
111
112
- The `WebViewScriptLoadedEvent` is a supporting data type for the data the event needs to pass from native to JavaScript.
112
-
- The `NativeProps` which is a definitions of the props that we can set on the component.
113
-
- The `codegenNativeComponent` statement that allows to codegenerate the code for the custom component and that defines a name for the component used to match the native implementations.
113
+
- The `NativeProps` which is a definition of the props that we can set on the component.
114
+
- The `codegenNativeComponent` statement that allows us to codegenerate the code for the custom component and that defines a name for the component used to match the native implementations.
114
115
115
-
As with Native Modules, you can have multiple specification files in the `specs/` directory. For more information about the types you can use, and the platform types these map to see the [appendix](appendix.md#codegen-typings).
116
+
As with Native Modules, you can have multiple specification files in the `specs/` directory. For more information about the types you can use, and the platform types these map to, see the [appendix](appendix.md#codegen-typings).
116
117
117
118
## 2. Configure Codegen to run
118
119
@@ -128,7 +129,7 @@ The specification is used by the React Native's Codegen tools to generate platfo
0 commit comments