Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReactNative's ref.measureLayout now takes a ref #15126

Merged
merged 4 commits into from
Mar 29, 2019

Conversation

elicwhite
Copy link
Member

The number is the reactTag which is found in product code with findNodeHandle. In order to get rid of findNodeHandle this needs to be able to be called with a ref. This PR now allows measureLayout to be passed a ref which must be a ref to a native node.

In Paper we will get the nativeTag for this ref, in Fabric, in a follow up, this will pull the node off the ref.canonical and call FabricUIManger with it.

@elicwhite
Copy link
Member Author

Lets not change NativeMethodsMixin or ReactNative.NativeComponent. Let's not make those more powerful now.

@sizebot
Copy link

sizebot commented Mar 16, 2019

Details of bundled changes.

Comparing: 103378b...36ded07

react-native-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactNativeRenderer-dev.js +0.1% +0.1% 617.76 KB 618.39 KB 132.22 KB 132.34 KB RN_FB_DEV
ReactNativeRenderer-prod.js 🔺+0.2% 🔺+0.2% 245.47 KB 245.88 KB 42.92 KB 42.99 KB RN_FB_PROD
ReactNativeRenderer-profiling.js +0.2% +0.2% 251.7 KB 252.11 KB 44.27 KB 44.34 KB RN_FB_PROFILING
ReactNativeRenderer-dev.js +0.1% +0.1% 617.67 KB 618.31 KB 132.19 KB 132.31 KB RN_OSS_DEV
ReactNativeRenderer-prod.js 🔺+0.2% 🔺+0.2% 245.48 KB 245.9 KB 42.92 KB 42.99 KB RN_OSS_PROD
ReactNativeRenderer-profiling.js +0.2% +0.2% 251.72 KB 252.13 KB 44.27 KB 44.34 KB RN_OSS_PROFILING
ReactFabric-dev.js +0.1% +0.1% 608.19 KB 608.82 KB 129.9 KB 130.02 KB RN_FB_DEV
ReactFabric-prod.js 🔺+0.2% 🔺+0.2% 239.57 KB 239.98 KB 41.72 KB 41.8 KB RN_FB_PROD
ReactFabric-profiling.js +0.2% +0.2% 244.89 KB 245.3 KB 43.09 KB 43.16 KB RN_FB_PROFILING
ReactFabric-dev.js +0.1% +0.1% 608.09 KB 608.73 KB 129.85 KB 129.98 KB RN_OSS_DEV
ReactFabric-prod.js 🔺+0.2% 🔺+0.2% 239.57 KB 239.98 KB 41.71 KB 41.79 KB RN_OSS_PROD
ReactFabric-profiling.js +0.2% +0.2% 244.9 KB 245.31 KB 43.09 KB 43.16 KB RN_OSS_PROFILING

Generated by 🚫 dangerJS

uiViewClassName: 'RCTView',
}));

[View].forEach(Component => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😆

@elicwhite elicwhite merged commit 2e02469 into facebook:master Mar 29, 2019
elicwhite added a commit to elicwhite/react that referenced this pull request Apr 4, 2019
The Fabric renderer was previously calling the paper UIManager's measure calls and passing the react tag. This PR changes the renderer to now call FabricUIManager passing the node instead.

One of the parts of this that feels more controversial is making NativeMethodsMixin and ReactNative.NativeComponent warn when calling measureLayout in Fabric. As Seb and I decided in facebook#15126, it doesn't make sense for a component created with one of these methods to require a native ref but not work the other way around. For example: a.measureLayout(b) might work but b.measureLayout(a) wouldn't. We figure we should keep these consistent and continue migrating things off of NativeMethodsMixin and NativeComponent.

If this becomes problematic for the Fabric rollout then we should revisit this.
@elicwhite elicwhite deleted the measure-layout-ref branch April 9, 2019 19:48
elicwhite added a commit that referenced this pull request Apr 9, 2019
* [React Native] Add tests to paper renderer for measure, measureLayout

* [React Native] measure calls will now call FabricUIManager

The Fabric renderer was previously calling the paper UIManager's measure calls and passing the react tag. This PR changes the renderer to now call FabricUIManager passing the node instead.

One of the parts of this that feels more controversial is making NativeMethodsMixin and ReactNative.NativeComponent warn when calling measureLayout in Fabric. As Seb and I decided in #15126, it doesn't make sense for a component created with one of these methods to require a native ref but not work the other way around. For example: a.measureLayout(b) might work but b.measureLayout(a) wouldn't. We figure we should keep these consistent and continue migrating things off of NativeMethodsMixin and NativeComponent.

If this becomes problematic for the Fabric rollout then we should revisit this.

* Fixing Flow

* Add FabricUIManager to externals for paper renderer

* import * as FabricUIManager from 'FabricUIManager';

* Update tests

* Shouldn't have removed UIManager import

* Update with the new tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants