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
@@ -220,159 +220,38 @@ Codegen can be configured in the `package.json` file of your Library. Add the fo
220
220
221
221
Android also requires to have the [React Gradle Plugin properly configured](new-architecture-app-intro#android-specifics) in your app.
222
222
223
-
## Preparing your JavaScript Codebase for the new React Native Renderer (Fabric)
223
+
## Migrating from `UIManager`JavaScript APIs
224
224
225
-
The new renderer, Fabric, doesn’t use the UIManager, so direct calls to UIManager will need to be migrated. Historically, calls to UIManager had some pretty complicated patterns. Fortunately, we’ve created new APIs that are much cleaner. These new APIs are forward compatible with Fabric, so you can migrate your code today, and the APIs will work properly when you turn on Fabric!
225
+
In the New Architecture, most `UIManager` methods will become available as instance methods on native component instances obtained via `ref`:
226
226
227
-
Fabric will be providing new type-safe JS APIs that are much more ergonomic than some of the patterns we've seen in product code today. These APIs require references to the underlying component, no longer using the result of `findNodeHandle`. `findNodeHandle` is used to search the tree for a native component given a class instance. This was breaking the React abstraction model. `findNodeHandle` is not compatible with React 18. Deprecation of `findNodeHandle` in React Native is similar to the [deprecation of `findDOMNode` in React DOM](https://reactjs.org/docs/strict-mode.html#warning-about-deprecated-finddomnode-usage).
228
-
229
-
While we know that all deprecations are a hassle, this guide is intended to help people update components as smoothly as possible. Here are the steps you need to take to get your JS codebase ready for Fabric:
230
-
231
-
1. Migrating findNodeHandle / getting a HostComponent
232
-
2. Migrating `.measure*()`
233
-
3. Migrating off `setNativeProps`
234
-
4. Move the call to `requireNativeComponent` to a separate file
235
-
5. Migrating off `dispatchViewManagerCommand`
236
-
6. Creating NativeCommands with `codegenNativeCommands`
237
-
238
-
### Migrating `findNodeHandle` / getting a `HostComponent`
239
-
240
-
Most of the migration work requires a HostComponent ref to access certain APIs that are only attached to host components (like View, Text, or ScrollView). HostComponents are the return value of calls to `requireNativeComponent`. `findNodeHandle` tunnels through multiple levels of component hierarchy to find the nearest native component.
241
-
242
-
As a concrete example, this code uses `findNodeHandle` to tunnel from `ParentComponent` through to the `View` rendered by `ChildComponent`.
We can’t convert this call to `this._ref.measure` because `this._ref` is an instance to `ChildComponent`, which is not a HostComponent and thus does not have a `measure` function.
277
-
278
-
`ChildComponent` renders a `View`, which is a HostComponent, so we need to get a reference to `View` instead. There are typically two approaches to getting what we need. If the component we need to get the ref from is a function component, using `forwardRef` is probably the right choice. If it is a class component with other public methods, adding a public method for getting the ref is an option. Here are examples of those two forms:
Let’stakealookatanexamplecalling`UIManager.measure`. Thiscodemightlooksomethinglike this
243
+
- Better developer ergonomics by removing the need for separately importing `UIManager` or calling `findNodeHandle`.
244
+
- Better performance by avoiding the node handle lookup step.
245
+
- Directionally aligned with [the analogous deprecation of `findDOMNode`](https://reactjs.org/docs/strict-mode.html#warning-about-deprecated-finddomnode-usage).
We will eventually deprecate `UIManager`. However, we recognize that migrations demand a high cost for many application and library authors. In order to minimize this cost, we plan to continuing supporting as many of the methods on `UIManager` as possible in the New Architecture.
**Support for `UIManager` methods in the New Architecture is actively being developed.** While we make progress here, early adopters can still experiment with the New Architecture by following these steps to migrate off common `UIManager` APIs:
0 commit comments