mirror of
https://github.com/status-im/react-native.git
synced 2025-02-27 00:20:31 +00:00
findNodeHandle -> ReactNative.findNodeHandle
Summary: findNodeHandle is considered an internal module. The one to use is ReactNative.findNodeHandle. We need to rely on this because we will have two different renderers and we need the renderers to inject themselves with findNodeHandle before it is used. I use ReactNative.findNodeHandle from inside the module because I think this leads to a cycle somewhere or might not play well with inline require otherwise. There is also one in UIManager but that is definitely a cycle so I'm going to try to avoid that one. Reviewed By: spicyj, bvaughn Differential Revision: D4533911 fbshipit-source-id: f771641ea5c5366ccbaff68c42202fa6f8c18cb3
This commit is contained in:
parent
3ca719072f
commit
57990b7970
@ -16,11 +16,11 @@ var InteractionManager = require('InteractionManager');
|
||||
var Interpolation = require('Interpolation');
|
||||
var NativeAnimatedHelper = require('NativeAnimatedHelper');
|
||||
var React = require('React');
|
||||
var ReactNative = require('ReactNative');
|
||||
var Set = require('Set');
|
||||
var SpringConfig = require('SpringConfig');
|
||||
var ViewStylePropTypes = require('ViewStylePropTypes');
|
||||
|
||||
var findNodeHandle = require('findNodeHandle');
|
||||
var flattenStyle = require('flattenStyle');
|
||||
var invariant = require('fbjs/lib/invariant');
|
||||
var requestAnimationFrame = require('fbjs/lib/requestAnimationFrame');
|
||||
@ -1661,14 +1661,14 @@ class AnimatedProps extends Animated {
|
||||
|
||||
__connectAnimatedView(): void {
|
||||
invariant(this.__isNative, 'Expected node to be marked as "native"');
|
||||
var nativeViewTag: ?number = findNodeHandle(this._animatedView);
|
||||
var nativeViewTag: ?number = ReactNative.findNodeHandle(this._animatedView);
|
||||
invariant(nativeViewTag != null, 'Unable to locate attached view in the native tree');
|
||||
NativeAnimatedAPI.connectAnimatedNodeToView(this.__getNativeTag(), nativeViewTag);
|
||||
}
|
||||
|
||||
__disconnectAnimatedView(): void {
|
||||
invariant(this.__isNative, 'Expected node to be marked as "native"');
|
||||
var nativeViewTag: ?number = findNodeHandle(this._animatedView);
|
||||
var nativeViewTag: ?number = ReactNative.findNodeHandle(this._animatedView);
|
||||
invariant(nativeViewTag != null, 'Unable to locate attached view in the native tree');
|
||||
NativeAnimatedAPI.disconnectAnimatedNodeFromView(this.__getNativeTag(), nativeViewTag);
|
||||
}
|
||||
@ -2204,7 +2204,7 @@ class AnimatedEvent {
|
||||
// Assume that the event containing `nativeEvent` is always the first argument.
|
||||
traverse(this._argMapping[0].nativeEvent, []);
|
||||
|
||||
const viewTag = findNodeHandle(viewRef);
|
||||
const viewTag = ReactNative.findNodeHandle(viewRef);
|
||||
|
||||
eventMappings.forEach((mapping) => {
|
||||
NativeAnimatedAPI.addAnimatedEventToView(viewTag, eventName, mapping);
|
||||
|
@ -15,12 +15,12 @@ const BoundingDimensions = require('BoundingDimensions');
|
||||
const Platform = require('Platform');
|
||||
const Position = require('Position');
|
||||
const React = require('React');
|
||||
const ReactNative = require('ReactNative');
|
||||
const TVEventHandler = require('TVEventHandler');
|
||||
const TouchEventUtils = require('fbjs/lib/TouchEventUtils');
|
||||
const UIManager = require('UIManager');
|
||||
const View = require('View');
|
||||
|
||||
const findNodeHandle = require('findNodeHandle');
|
||||
const keyMirror = require('fbjs/lib/keyMirror');
|
||||
const normalizeColor = require('normalizeColor');
|
||||
|
||||
@ -323,7 +323,7 @@ var TouchableMixin = {
|
||||
|
||||
this._tvEventHandler = new TVEventHandler();
|
||||
this._tvEventHandler.enable(this, function(cmp, evt) {
|
||||
var myTag = findNodeHandle(cmp);
|
||||
var myTag = ReactNative.findNodeHandle(cmp);
|
||||
evt.dispatchConfig = {};
|
||||
if (myTag === evt.tag) {
|
||||
if (evt.eventType === 'focus') {
|
||||
|
@ -7,14 +7,15 @@
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @providesModule NativeMethodsMixin
|
||||
* @flow
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var ReactNative = require('ReactNative');
|
||||
var ReactNativeAttributePayload = require('ReactNativeAttributePayload');
|
||||
var TextInputState = require('TextInputState');
|
||||
var UIManager = require('UIManager');
|
||||
|
||||
var findNodeHandle = require('findNodeHandle');
|
||||
var invariant = require('fbjs/lib/invariant');
|
||||
|
||||
type MeasureOnSuccessCallback = (
|
||||
@ -84,7 +85,7 @@ var NativeMethodsMixin = {
|
||||
*/
|
||||
measure: function(callback: MeasureOnSuccessCallback) {
|
||||
UIManager.measure(
|
||||
findNodeHandle(this),
|
||||
ReactNative.findNodeHandle(this),
|
||||
mountSafeCallback(this, callback)
|
||||
);
|
||||
},
|
||||
@ -106,7 +107,7 @@ var NativeMethodsMixin = {
|
||||
*/
|
||||
measureInWindow: function(callback: MeasureInWindowOnSuccessCallback) {
|
||||
UIManager.measureInWindow(
|
||||
findNodeHandle(this),
|
||||
ReactNative.findNodeHandle(this),
|
||||
mountSafeCallback(this, callback)
|
||||
);
|
||||
},
|
||||
@ -117,7 +118,7 @@ var NativeMethodsMixin = {
|
||||
* are relative to the origin x, y of the ancestor view.
|
||||
*
|
||||
* As always, to obtain a native node handle for a component, you can use
|
||||
* `React.findNodeHandle(component)`.
|
||||
* `ReactNative.findNodeHandle(component)`.
|
||||
*/
|
||||
measureLayout: function(
|
||||
relativeToNativeNode: number,
|
||||
@ -125,7 +126,7 @@ var NativeMethodsMixin = {
|
||||
onFail: () => void /* currently unused */
|
||||
) {
|
||||
UIManager.measureLayout(
|
||||
findNodeHandle(this),
|
||||
ReactNative.findNodeHandle(this),
|
||||
relativeToNativeNode,
|
||||
mountSafeCallback(this, onFail),
|
||||
mountSafeCallback(this, onSuccess)
|
||||
@ -139,12 +140,6 @@ var NativeMethodsMixin = {
|
||||
* Manipulation](docs/direct-manipulation.html)).
|
||||
*/
|
||||
setNativeProps: function(nativeProps: Object) {
|
||||
if (!this.viewConfig) {
|
||||
var ctor = this.constructor;
|
||||
var componentName = ctor.displayName || ctor.name || '<Unknown Component>';
|
||||
invariant(false, componentName + ' "viewConfig" is not defined.');
|
||||
}
|
||||
|
||||
if (__DEV__) {
|
||||
warnForStyleProps(nativeProps, this.viewConfig.validAttributes);
|
||||
}
|
||||
@ -155,7 +150,7 @@ var NativeMethodsMixin = {
|
||||
);
|
||||
|
||||
UIManager.updateView(
|
||||
findNodeHandle(this),
|
||||
(ReactNative.findNodeHandle(this) : any),
|
||||
this.viewConfig.uiViewClassName,
|
||||
updatePayload
|
||||
);
|
||||
@ -166,14 +161,14 @@ var NativeMethodsMixin = {
|
||||
* will depend on the platform and type of view.
|
||||
*/
|
||||
focus: function() {
|
||||
TextInputState.focusTextInput(findNodeHandle(this));
|
||||
TextInputState.focusTextInput(ReactNative.findNodeHandle(this));
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes focus from an input or view. This is the opposite of `focus()`.
|
||||
*/
|
||||
blur: function() {
|
||||
TextInputState.blurTextInput(findNodeHandle(this));
|
||||
TextInputState.blurTextInput(ReactNative.findNodeHandle(this));
|
||||
},
|
||||
};
|
||||
|
||||
@ -217,7 +212,7 @@ function mountSafeCallback(
|
||||
callback: ?Function
|
||||
): any {
|
||||
return function() {
|
||||
if (!callback || (context.isMounted && !context.isMounted())) {
|
||||
if (!callback || (typeof context.isMounted === 'function' && !context.isMounted())) {
|
||||
return undefined;
|
||||
}
|
||||
return callback.apply(context, arguments);
|
||||
|
Loading…
x
Reference in New Issue
Block a user