diff --git a/examples/components/ActivityIndicator/ActivityIndicatorExample.js b/examples/components/ActivityIndicator/ActivityIndicatorExample.js index 66595b56..c19c12d7 100644 --- a/examples/components/ActivityIndicator/ActivityIndicatorExample.js +++ b/examples/components/ActivityIndicator/ActivityIndicatorExample.js @@ -129,7 +129,7 @@ const examples = [ render() { return ( - + - + Disabled TouchableOpacity - + Enabled TouchableOpacity @@ -321,7 +321,7 @@ var TouchableDisabled = React.createClass({ animationVelocity={0} underlayColor="rgb(210, 230, 255)" style={[styles.row, styles.block]} - onPress={() => console.log('custom THW text - highlight')}> + onPress={action('TouchableHighlight')}> Disabled TouchableHighlight @@ -332,7 +332,7 @@ var TouchableDisabled = React.createClass({ animationVelocity={0} underlayColor="rgb(210, 230, 255)" style={[styles.row, styles.block]} - onPress={() => console.log('custom THW text - highlight')}> + onPress={action('TouchableHighlight')}> Enabled TouchableHighlight diff --git a/src/apis/StyleSheet/__tests__/resolveTransform-test.js b/src/apis/StyleSheet/__tests__/resolveTransform-test.js index a7143af6..642ddb71 100644 --- a/src/apis/StyleSheet/__tests__/resolveTransform-test.js +++ b/src/apis/StyleSheet/__tests__/resolveTransform-test.js @@ -15,7 +15,8 @@ describe('apis/StyleSheet/resolveTransform', () => { resolveTransform(resolvedStyle, style); expect(resolvedStyle).toEqual({ - transform: 'scaleX(20) translateX(20px) rotate(20deg)' }); + transform: 'scaleX(20) translateX(20px) rotate(20deg)' + }); }); test('transformMatrix', () => { diff --git a/src/modules/NativeMethodsMixin/index.js b/src/modules/NativeMethodsMixin/index.js index 3e2e248f..ba50f9bc 100644 --- a/src/modules/NativeMethodsMixin/index.js +++ b/src/modules/NativeMethodsMixin/index.js @@ -6,33 +6,9 @@ * @flow */ -import { Component } from 'react'; import findNodeHandle from '../findNodeHandle'; import UIManager from '../../apis/UIManager'; -type MeasureInWindowOnSuccessCallback = ( - x: number, - y: number, - width: number, - height: number, -) => void - -type MeasureLayoutOnSuccessCallback = ( - left: number, - top: number, - width: number, - height: number -) => void - -type MeasureOnSuccessCallback = ( - x: number, - y: number, - width: number, - height: number, - pageX: number, - pageY: number -) => void - const NativeMethodsMixin = { /** * Removes focus from an input or view. This is the opposite of `focus()`. @@ -52,11 +28,8 @@ const NativeMethodsMixin = { /** * Determines the position and dimensions of the view */ - measure(callback: MeasureOnSuccessCallback) { - UIManager.measure( - findNodeHandle(this), - mountSafeCallback(this, callback) - ); + measure(callback) { + UIManager.measure(findNodeHandle(this), callback); }, /** @@ -74,50 +47,23 @@ const NativeMethodsMixin = { * Note that these measurements are not available until after the rendering * has been completed in native. */ - measureInWindow(callback: MeasureInWindowOnSuccessCallback) { - UIManager.measureInWindow( - findNodeHandle(this), - mountSafeCallback(this, callback) - ); + measureInWindow(callback) { + UIManager.measureInWindow(findNodeHandle(this), callback); }, /** * Measures the view relative to another view (usually an ancestor) */ - measureLayout( - relativeToNativeNode: Object, - onSuccess: MeasureLayoutOnSuccessCallback, - onFail: () => void /* currently unused */ - ) { - UIManager.measureLayout( - findNodeHandle(this), - relativeToNativeNode, - mountSafeCallback(this, onFail), - mountSafeCallback(this, onSuccess) - ); + measureLayout(relativeToNativeNode, onSuccess, onFail) { + UIManager.measureLayout(findNodeHandle(this), relativeToNativeNode, onFail, onSuccess); }, /** * This function sends props straight to the underlying DOM node. */ setNativeProps(nativeProps: Object) { - UIManager.updateView( - findNodeHandle(this), - nativeProps, - this - ); + UIManager.updateView(findNodeHandle(this), nativeProps, this); } }; -/** - * In the future, we should cleanup callbacks by cancelling them instead of - * using this. - */ -const mountSafeCallback = (context: Component, callback: ?Function) => (...args) => { - if (!callback) { - return undefined; - } - return callback.apply(context, args); -}; - module.exports = NativeMethodsMixin; diff --git a/src/modules/ReactNativePropRegistry/index.js b/src/modules/ReactNativePropRegistry/index.js index e13d00a9..38bb5514 100644 --- a/src/modules/ReactNativePropRegistry/index.js +++ b/src/modules/ReactNativePropRegistry/index.js @@ -14,15 +14,19 @@ const emptyObject = {}; const objects = {}; +const prefix = 'r'; let uniqueID = 1; +const createKey = (id) => `${prefix}${id}`; + class ReactNativePropRegistry { static register(object: Object): number { let id = ++uniqueID; if (process.env.NODE_ENV !== 'production') { Object.freeze(object); } - objects[`${id}`] = object; + const key = createKey(id); + objects[key] = object; return id; } @@ -32,8 +36,8 @@ class ReactNativePropRegistry { // we want it to be a no-op when the value is false or null return emptyObject; } - - const object = objects[`${id}`]; + const key = createKey(id); + const object = objects[key]; if (!object) { console.warn('Invalid style with id `' + id + '`. Skipping ...'); return emptyObject;