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
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.
236
-
237
-
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
+21-14Lines changed: 21 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -120,24 +120,31 @@ As with Native Modules, you can have multiple specification files in the `specs/
120
120
The specification is used by the React Native's Codegen tools to generate platform specific interfaces and boilerplate for us. To do this, Codegen needs to know where to find our specification and what to do with it. Update your `package.json` to include:
121
121
122
122
```json package.json
123
-
"start": "react-native start",
124
-
"test": "jest"
125
-
},
126
-
// highlight-start
127
-
"codegenConfig": {
128
-
"name": "AppSpec",
129
-
"type": "components",
130
-
"jsSrcsDir": "specs",
131
-
"android": {
132
-
"javaPackageName": "com.webview"
133
-
}
134
-
},
135
-
// highlight-end
136
-
"dependencies": {
123
+
"start": "react-native start",
124
+
"test": "jest"
125
+
},
126
+
// highlight-start
127
+
"codegenConfig": {
128
+
"name": "AppSpec",
129
+
"type": "components",
130
+
"jsSrcsDir": "specs",
131
+
"android": {
132
+
"javaPackageName": "com.webview"
133
+
},
134
+
"ios": {
135
+
"componentProvider": {
136
+
"CustomWebView": "RCTWebView"
137
+
}
138
+
}
139
+
},
140
+
// highlight-end
141
+
"dependencies": {
137
142
```
138
143
139
144
With everything wired up for Codegen, we need to prepare our native code to hook into our generated code.
140
145
146
+
Note that for iOS, we are declaratively mapping the name of the JS component that is exported by the spec (`CustomWebView`) with the iOS class that will implement the component natively.
147
+
141
148
## 2. Building your Native Code
142
149
143
150
Now it's time to write the native platform code so that when React requires to render a view, the platform can create the right native view and can render it on screen.
0 commit comments