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
React Native libraries are typically installed from the [npm registry](https://www.npmjs.com/) using a Node.js package manager such as [npm CLI](https://docs.npmjs.com/cli/npm) or [Yarn 经典版(v1)](https://classic.yarnpkg.com/en/).
That's it! Next time you build your app the native code will be linked thanks to the [autolinking](https://github.com/react-native-community/cli/blob/main/docs/autolinking.md)mechanism.
Sometimes, you need to measure the current layout to apply some changes to the overall layout or to make decisions and call some specific logic.
3
+
有时,您需要测量当前布局以应用某些更改或做出决策并调用某些特定逻辑。
4
4
5
-
React Native provides some native methods to know what are the measurements of the views.
5
+
React Native 提供了一些原生方法来了解视图的测量值。
6
6
7
-
The best way to invoke those methods is in a `useLayoutEffect`hook: this will give you the most recent values for those measurements and it will let you apply changes in the same frame when the measurements are computed.
@@ -26,28 +26,28 @@ function AComponent(children) {
26
26
}
27
27
```
28
28
29
-
:::note
30
-
The methods described here are available on most of the default components provided by React Native. However, they are _not_ available on composite components that aren't directly backed by a native view. This will generally include most components that you define in your own app.
Determines the location on screen (`x` and `y`), `width`, and `height` in the viewport of the given view. Returns the values via an async callback. If successful, the callback will be called with the following arguments:
Determines the location (`x` and `y`) of the given view in the window and returns the values via an async callback. If the React root view is embedded in another native view, this will give you the absolute coordinates. If successful, the callback will be called with the following arguments:
0 commit comments