Skip to content

Commit 06a87be

Browse files
committed
Updates from Wed 18 Mar
- [ReactNative] Add AsyncStorageTest | Spencer Ahrens - [ReactNative] Add timers integration test | Spencer Ahrens - [ReactNative] Remove ExpandingText | Tadeu Zagallo - [TouchableHighlight] Preserve underlay style when restoring inactive props | Christopher Chedeau - clean flow errors in react-native-github | Basil Hosmer - [ReactNative] Sort React Native exports into two groups, Components and APIs | Christopher Chedeau - [ReactNative] Rename Slider to SliderIOS | Tadeu Zagallo - [react_native] JS files from D1919491: Improve JS logging | Martin Kosiba - [ReactNative] Add TimerExample | Spencer Ahrens - [RFC][ReactNative] increase timer resolution | Spencer Ahrens - [ReactNative] Strip prefixes from NativeModules keys | Spencer Ahrens - [ReactNative] Small docs cleanup in ActivityIndicatorIOS and DatePickerIOS | Christopher Chedeau - [ReactNative] Improvements on perf measurement output | Jing Chen - [ReactNative] Clean up Touchable PropTypes | Christopher Chedeau - [ReactKit] Fail tests when redbox shows up | Alex Kotliarskyi
1 parent 55598f9 commit 06a87be

75 files changed

Lines changed: 794 additions & 372 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.flowconfig

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,14 @@
99

1010
# Ignore react-tools where there are overlaps, but don't ignore anything that
1111
# react-native relies on
12-
.*/node_modules/react-tools/src/vendor/.*
12+
.*/node_modules/react-tools/src/vendor/core/ExecutionEnvironment.js
1313
.*/node_modules/react-tools/src/browser/.*
1414
.*/node_modules/react-tools/src/core/ReactInstanceHandles.js
1515
.*/node_modules/react-tools/src/event/.*
1616

1717
# Ignore jest
1818
.*/react-native/node_modules/jest-cli/.*
1919

20-
# Ignore Libraries
21-
.*/Libraries/.*
22-
2320
[include]
2421

2522
[libs]

Examples/2048/Game2048.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,16 @@ class GameEndOverlay extends React.Component {
129129
}
130130

131131
class Game2048 extends React.Component {
132+
startX: number;
133+
startY: number;
134+
132135
constructor(props) {
133136
super(props);
134137
this.state = {
135138
board: new GameBoard(),
136139
};
140+
this.startX = 0;
141+
this.startY = 0;
137142
}
138143

139144
restartGame() {

Examples/Movies/MovieScreen.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
var React = require('react-native');
88
var {
9-
ExpandingText,
109
Image,
1110
PixelRatio,
1211
ScrollView,
@@ -40,10 +39,9 @@ var MovieScreen = React.createClass({
4039
</View>
4140
</View>
4241
<View style={styles.separator} />
43-
<ExpandingText
44-
truncLength={200}
45-
text={this.props.movie.synopsis}
46-
/>
42+
<Text>
43+
{this.props.movie.synopsis}
44+
</Text>
4745
<View style={styles.separator} />
4846
<Cast actors={this.props.movie.abridged_cast} />
4947
</ScrollView>

Examples/UIExplorer/CameraRollExample.ios.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ var React = require('react-native');
77
var {
88
CameraRoll,
99
Image,
10-
Slider,
10+
SliderIOS,
1111
StyleSheet,
1212
SwitchIOS,
1313
Text,
@@ -35,7 +35,7 @@ var CameraRollExample = React.createClass({
3535
onValueChange={this._onSwitchChange}
3636
value={this.state.bigImages} />
3737
<Text>{(this.state.bigImages ? 'Big' : 'Small') + ' Images'}</Text>
38-
<Slider
38+
<SliderIOS
3939
value={this.state.sliderValue}
4040
onValueChange={this._onSliderChange}
4141
/>

Examples/UIExplorer/ExpandingTextExample.js

Lines changed: 0 additions & 52 deletions
This file was deleted.

Examples/UIExplorer/ListViewPagingExample.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,11 @@ var ListViewPagingExample = React.createClass({
9999
};
100100
},
101101

102-
renderRow: function(rowData, sectionID, rowID) {
102+
renderRow: function(rowData: string, sectionID: string, rowID: string): ReactElement {
103103
return (<Thumb text={rowData}/>);
104104
},
105105

106-
renderSectionHeader: function(sectionData, sectionID) {
106+
renderSectionHeader: function(sectionData: string, sectionID: string) {
107107
return (
108108
<View style={styles.section}>
109109
<Text style={styles.text}>
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
var React = require('react-native');
77
var {
8-
Slider,
8+
SliderIOS,
99
Text,
1010
StyleSheet,
1111
View,
@@ -24,7 +24,7 @@ var SliderExample = React.createClass({
2424
<Text style={styles.text} >
2525
{this.state.value}
2626
</Text>
27-
<Slider
27+
<SliderIOS
2828
style={styles.slider}
2929
onValueChange={(value) => this.setState({value: value})} />
3030
</View>
@@ -45,11 +45,11 @@ var styles = StyleSheet.create({
4545
},
4646
});
4747

48-
exports.title = '<Slider>';
48+
exports.title = '<SliderIOS>';
4949
exports.description = 'Slider input for numeric values';
5050
exports.examples = [
5151
{
52-
title: 'Slider',
52+
title: 'SliderIOS',
5353
render() { return <SliderExample />; }
5454
}
5555
];
Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
/**
2+
* Copyright 2004-present Facebook. All Rights Reserved.
3+
*/
4+
'use strict';
5+
6+
var React = require('react-native');
7+
var {
8+
AlertIOS,
9+
StyleSheet,
10+
Text,
11+
TimerMixin,
12+
TouchableHighlight,
13+
View,
14+
} = React;
15+
16+
var Button = React.createClass({
17+
render: function() {
18+
return (
19+
<TouchableHighlight
20+
onPress={this.props.onPress}
21+
style={styles.button}
22+
underlayColor="#eeeeee">
23+
<Text>
24+
{this.props.children}
25+
</Text>
26+
</TouchableHighlight>
27+
);
28+
},
29+
});
30+
31+
var TimerTester = React.createClass({
32+
mixins: [TimerMixin],
33+
34+
render: function() {
35+
var args = 'fn' + (this.props.dt !== undefined ? ', ' + this.props.dt : '');
36+
return (
37+
<Button onPress={this._run}>
38+
Measure: {this.props.type}({args}) - {this._ii || 0}
39+
</Button>
40+
);
41+
},
42+
43+
_run: function() {
44+
if (!this._start) {
45+
var d = new Date();
46+
this._start = d.getTime();
47+
this._iters = 100;
48+
this._ii = 0;
49+
if (this.props.type === 'setTimeout') {
50+
if (this.props.dt < 1) {
51+
this._iters = 5000;
52+
} else if (this.props.dt > 20) {
53+
this._iters = 10;
54+
}
55+
this._timerFn = () => this.setTimeout(this._run, this.props.dt);
56+
} else if (this.props.type === 'requestAnimationFrame') {
57+
this._timerFn = () => this.requestAnimationFrame(this._run);
58+
} else if (this.props.type === 'setImmediate') {
59+
this._iters = 5000;
60+
this._timerFn = () => this.setImmediate(this._run);
61+
} else if (this.props.type === 'setInterval') {
62+
this._iters = 30; // Only used for forceUpdate periodicidy
63+
this._timerFn = null;
64+
this._handle = this.setInterval(this._run, this.props.dt);
65+
}
66+
}
67+
if (this._ii >= this._iters && !this._handle) {
68+
var d = new Date();
69+
var e = (d.getTime() - this._start);
70+
var msg = 'Finished ' + this._ii + ' ' + this.props.type + ' calls.\n' +
71+
'Elapsed time: ' + e + ' ms\n' + (e / this._ii) + ' ms / iter';
72+
console.log(msg);
73+
AlertIOS.alert(msg);
74+
this._start = null;
75+
this.forceUpdate(() => { this._ii = 0; });
76+
return;
77+
}
78+
this._ii++;
79+
// Only re-render occasionally so we don't slow down timers.
80+
if (this._ii % (this._iters / 5) === 0) {
81+
this.forceUpdate();
82+
}
83+
this._timerFn && this._timerFn();
84+
},
85+
86+
clear: function() {
87+
this.clearInterval(this._handle); // invalid handles are ignored
88+
if (this._handle) {
89+
// Configure things so we can do a final run to update UI and reset state.
90+
this._handle = null;
91+
this._iters = this._ii;
92+
this._run();
93+
}
94+
},
95+
});
96+
97+
var styles = StyleSheet.create({
98+
button: {
99+
borderColor: 'gray',
100+
borderRadius: 8,
101+
borderWidth: 1,
102+
padding: 10,
103+
margin: 5,
104+
alignItems: 'center',
105+
justifyContent: 'center',
106+
},
107+
});
108+
109+
exports.framework = 'React';
110+
exports.title = 'Timers, TimerMixin';
111+
exports.description = 'The TimerMixin provides timer functions for executing ' +
112+
'code in the future that are safely cleaned up when the component unmounts.';
113+
114+
exports.examples = [
115+
{
116+
title: 'this.setTimeout(fn, t)',
117+
description: 'Execute function fn t milliseconds in the future. If ' +
118+
't === 0, it will be enqueued immediately in the next event loop. ' +
119+
'Larger values will fire on the closest frame.',
120+
render: function() {
121+
return (
122+
<View>
123+
<TimerTester type="setTimeout" dt={0} />
124+
<TimerTester type="setTimeout" dt={1} />
125+
<TimerTester type="setTimeout" dt={100} />
126+
</View>
127+
);
128+
},
129+
},
130+
{
131+
title: 'this.requestAnimationFrame(fn)',
132+
description: 'Execute function fn on the next frame.',
133+
render: function() {
134+
return (
135+
<View>
136+
<TimerTester type="requestAnimationFrame" />
137+
</View>
138+
);
139+
},
140+
},
141+
{
142+
title: 'this.setImmediate(fn)',
143+
description: 'Execute function fn at the end of the current JS event loop.',
144+
render: function() {
145+
return (
146+
<View>
147+
<TimerTester type="setImmediate" />
148+
</View>
149+
);
150+
},
151+
},
152+
{
153+
title: 'this.setInterval(fn, t)',
154+
description: 'Execute function fn every t milliseconds until cancelled ' +
155+
'or component is unmounted.',
156+
render: function() {
157+
var IntervalExample = React.createClass({
158+
getInitialState: function() {
159+
return {
160+
showTimer: true,
161+
};
162+
},
163+
164+
render: function() {
165+
if (this.state.showTimer) {
166+
var timer =
167+
<TimerTester ref="interval" dt={25} type="setInterval" />;
168+
var toggleText = 'Unmount timer';
169+
} else {
170+
var timer = null;
171+
var toggleText = 'Mount new timer';
172+
}
173+
return (
174+
<View>
175+
{timer}
176+
<Button onPress={() => this.refs.interval.clear() }>
177+
Clear interval
178+
</Button>
179+
<Button onPress={this._toggleTimer}>
180+
{toggleText}
181+
</Button>
182+
</View>
183+
);
184+
},
185+
186+
_toggleTimer: function() {
187+
this.setState({showTimer: !this.state.showTimer});
188+
},
189+
});
190+
return <IntervalExample />;
191+
},
192+
},
193+
];

0 commit comments

Comments
 (0)