Skip to content

Commit e20b097

Browse files
chore: fix typos, grammar, and formatting in Fabric components guide (facebook#4315)
Co-authored-by: Nicola Corti <[email protected]>
1 parent 0082221 commit e20b097

File tree

3 files changed

+20
-19
lines changed

3 files changed

+20
-19
lines changed

docs/fabric-native-components-android.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ The `ReactWebView` extends the Android `WebView` so you can reuse all the proper
187187

188188
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.
189189

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:
191191

192192
- grab a reference to the `ReactContext`;
193193
- retrieve the `surfaceId` of the view that you are presenting;
@@ -327,7 +327,7 @@ class ReactWebViewManager(context: ReactApplicationContext) : SimpleViewManager<
327327
</TabItem>
328328
</Tabs>
329329

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.
331331

332332
It holds a reference of the `CustomWebViewManagerDelegate`, another element generated by Codegen.
333333

@@ -341,7 +341,7 @@ Finally, if the component can emit an event, you need to map the event name by o
341341

342342
### 4. Write the `ReactWebViewPackage`
343343

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.
345345

346346
This is the code for the `ReactWebViewPackage`:
347347

docs/fabric-native-components-ios.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ You can [manually run](the-new-architecture/codegen-cli) the Codegen, however it
1818
```bash
1919
cd ios
2020
bundle install
21-
bundle exec pods install
21+
bundle exec pod install
2222
```
2323

2424
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:
193193
194194
- the `@interface` implements two protocols:
195195
- `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`;
198198
- 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;
201201
- the `urlIsValid:(std::string)propString` method that checks whether the URL received as prop is valid;
202202
- the `eventEmitter` method which is a utility to retrieve a strongly typed `eventEmitter` instance
203203
- 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
212212
#import "AppDelegate.h"
213213
214214
#import <React/RCTBundleURLProvider.h>
215+
// highlight-start
215216
#import <React/RCTBridge+Private.h>
216-
// highlight-next-line
217217
#import "RCTWebView.h"
218-
218+
// highlight-end
219219
@implementation AppDelegate
220220
// ...
221221
// highlight-start
@@ -230,9 +230,9 @@ Update the `AppDelegate.mm` to make your application aware of our custom WebView
230230
@end
231231
```
232232

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.
234234

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`.
236236

237237
Finally, it returns the new dictionary.
238238

docs/fabric-native-components.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import {FabricNativeComponentsAndroid,FabricNativeComponentsIOS} from './\_fabri
1010

1111
# Native Components
1212

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.
1414

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:
1616

1717
1. Define a JavaScript specification using Flow or TypeScript.
1818
2. Configure the dependencies management system to generate code from the provided spec and to be auto-linked.
@@ -27,7 +27,7 @@ npx @react-native-community/cli@latest init Demo --install-pods false
2727

2828
## Creating a WebView Component
2929

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.
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.
3131

3232
Let's start by creating the folders structure to hold our component's code:
3333

@@ -101,6 +101,7 @@ type NativeProps = $ReadOnly<{|
101101
export default (codegenNativeComponent<NativeProps>(
102102
'CustomWebView',
103103
): HostComponent<NativeProps>);
104+
104105
```
105106

106107
</TabItem>
@@ -109,10 +110,10 @@ export default (codegenNativeComponent<NativeProps>(
109110
This specification is composed of three main parts, exluding the imports:
110111

111112
- 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.
114115

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).
116117

117118
## 2. Configure Codegen to run
118119

@@ -128,7 +129,7 @@ The specification is used by the React Native's Codegen tools to generate platfo
128129
"type": "components",
129130
"jsSrcsDir": "specs",
130131
"android": {
131-
"javaPackageName": "com.nativelocalstorage"
132+
"javaPackageName": "com.webview"
132133
}
133134
},
134135
// highlight-end

0 commit comments

Comments
 (0)