Skip to content

Commit 351c0ac

Browse files
committed
Minor changes
1 parent 877c0d2 commit 351c0ac

File tree

5 files changed

+21
-70
lines changed

5 files changed

+21
-70
lines changed

examples/components/ActivityIndicator/ActivityIndicatorExample.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ const examples = [
129129
render() {
130130
return (
131131
<View style={[styles.horizontal, styles.centering]}>
132-
<ActivityIndicator size="40" />
132+
<ActivityIndicator size={40} />
133133
<ActivityIndicator
134134
style={{ marginLeft: 20, transform: [ {scale: 1.5} ] }}
135135
size="large"

examples/components/Touchable/TouchableExample.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -307,11 +307,11 @@ var TouchableDisabled = React.createClass({
307307
render: function() {
308308
return (
309309
<View>
310-
<TouchableOpacity disabled={true} style={[styles.row, styles.block]}>
310+
<TouchableOpacity disabled={true} style={[styles.row, styles.block]} onPress={action('TouchableOpacity')}>
311311
<Text style={styles.disabledButton}>Disabled TouchableOpacity</Text>
312312
</TouchableOpacity>
313313

314-
<TouchableOpacity disabled={false} style={[styles.row, styles.block]}>
314+
<TouchableOpacity disabled={false} style={[styles.row, styles.block]} onPress={action('TouchableOpacity')}>
315315
<Text style={styles.button}>Enabled TouchableOpacity</Text>
316316
</TouchableOpacity>
317317

@@ -321,7 +321,7 @@ var TouchableDisabled = React.createClass({
321321
animationVelocity={0}
322322
underlayColor="rgb(210, 230, 255)"
323323
style={[styles.row, styles.block]}
324-
onPress={() => console.log('custom THW text - highlight')}>
324+
onPress={action('TouchableHighlight')}>
325325
<Text style={styles.disabledButton}>
326326
Disabled TouchableHighlight
327327
</Text>
@@ -332,7 +332,7 @@ var TouchableDisabled = React.createClass({
332332
animationVelocity={0}
333333
underlayColor="rgb(210, 230, 255)"
334334
style={[styles.row, styles.block]}
335-
onPress={() => console.log('custom THW text - highlight')}>
335+
onPress={action('TouchableHighlight')}>
336336
<Text style={styles.button}>
337337
Enabled TouchableHighlight
338338
</Text>

src/apis/StyleSheet/__tests__/resolveTransform-test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ describe('apis/StyleSheet/resolveTransform', () => {
1515
resolveTransform(resolvedStyle, style);
1616

1717
expect(resolvedStyle).toEqual({
18-
transform: 'scaleX(20) translateX(20px) rotate(20deg)' });
18+
transform: 'scaleX(20) translateX(20px) rotate(20deg)'
19+
});
1920
});
2021

2122
test('transformMatrix', () => {

src/modules/NativeMethodsMixin/index.js

Lines changed: 7 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,9 @@
66
* @flow
77
*/
88

9-
import { Component } from 'react';
109
import findNodeHandle from '../findNodeHandle';
1110
import UIManager from '../../apis/UIManager';
1211

13-
type MeasureInWindowOnSuccessCallback = (
14-
x: number,
15-
y: number,
16-
width: number,
17-
height: number,
18-
) => void
19-
20-
type MeasureLayoutOnSuccessCallback = (
21-
left: number,
22-
top: number,
23-
width: number,
24-
height: number
25-
) => void
26-
27-
type MeasureOnSuccessCallback = (
28-
x: number,
29-
y: number,
30-
width: number,
31-
height: number,
32-
pageX: number,
33-
pageY: number
34-
) => void
35-
3612
const NativeMethodsMixin = {
3713
/**
3814
* Removes focus from an input or view. This is the opposite of `focus()`.
@@ -52,11 +28,8 @@ const NativeMethodsMixin = {
5228
/**
5329
* Determines the position and dimensions of the view
5430
*/
55-
measure(callback: MeasureOnSuccessCallback) {
56-
UIManager.measure(
57-
findNodeHandle(this),
58-
mountSafeCallback(this, callback)
59-
);
31+
measure(callback) {
32+
UIManager.measure(findNodeHandle(this), callback);
6033
},
6134

6235
/**
@@ -74,50 +47,23 @@ const NativeMethodsMixin = {
7447
* Note that these measurements are not available until after the rendering
7548
* has been completed in native.
7649
*/
77-
measureInWindow(callback: MeasureInWindowOnSuccessCallback) {
78-
UIManager.measureInWindow(
79-
findNodeHandle(this),
80-
mountSafeCallback(this, callback)
81-
);
50+
measureInWindow(callback) {
51+
UIManager.measureInWindow(findNodeHandle(this), callback);
8252
},
8353

8454
/**
8555
* Measures the view relative to another view (usually an ancestor)
8656
*/
87-
measureLayout(
88-
relativeToNativeNode: Object,
89-
onSuccess: MeasureLayoutOnSuccessCallback,
90-
onFail: () => void /* currently unused */
91-
) {
92-
UIManager.measureLayout(
93-
findNodeHandle(this),
94-
relativeToNativeNode,
95-
mountSafeCallback(this, onFail),
96-
mountSafeCallback(this, onSuccess)
97-
);
57+
measureLayout(relativeToNativeNode, onSuccess, onFail) {
58+
UIManager.measureLayout(findNodeHandle(this), relativeToNativeNode, onFail, onSuccess);
9859
},
9960

10061
/**
10162
* This function sends props straight to the underlying DOM node.
10263
*/
10364
setNativeProps(nativeProps: Object) {
104-
UIManager.updateView(
105-
findNodeHandle(this),
106-
nativeProps,
107-
this
108-
);
109-
}
110-
};
111-
112-
/**
113-
* In the future, we should cleanup callbacks by cancelling them instead of
114-
* using this.
115-
*/
116-
const mountSafeCallback = (context: Component, callback: ?Function) => (...args) => {
117-
if (!callback) {
118-
return undefined;
65+
UIManager.updateView(findNodeHandle(this), nativeProps, this);
11966
}
120-
return callback.apply(context, args);
12167
};
12268

12369
module.exports = NativeMethodsMixin;

src/modules/ReactNativePropRegistry/index.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,19 @@
1414

1515
const emptyObject = {};
1616
const objects = {};
17+
const prefix = 'r';
1718
let uniqueID = 1;
1819

20+
const createKey = (id) => `${prefix}${id}`;
21+
1922
class ReactNativePropRegistry {
2023
static register(object: Object): number {
2124
let id = ++uniqueID;
2225
if (process.env.NODE_ENV !== 'production') {
2326
Object.freeze(object);
2427
}
25-
objects[`${id}`] = object;
28+
const key = createKey(id);
29+
objects[key] = object;
2630
return id;
2731
}
2832

@@ -32,8 +36,8 @@ class ReactNativePropRegistry {
3236
// we want it to be a no-op when the value is false or null
3337
return emptyObject;
3438
}
35-
36-
const object = objects[`${id}`];
39+
const key = createKey(id);
40+
const object = objects[key];
3741
if (!object) {
3842
console.warn('Invalid style with id `' + id + '`. Skipping ...');
3943
return emptyObject;

0 commit comments

Comments
 (0)