Skip to content

Commit

Permalink
Fix errors uncovered by v0.19.0
Browse files Browse the repository at this point in the history
Reviewed By: mroch

Differential Revision: D2706663

fb-gh-sync-id: 017c91bab849bf18767cacd2ebe32d1a1b10c715
  • Loading branch information
gabelevi authored and facebook-github-bot-9 committed Dec 2, 2015
1 parent d4d41f9 commit 892dd5b
Show file tree
Hide file tree
Showing 24 changed files with 168 additions and 41 deletions.
12 changes: 8 additions & 4 deletions Examples/UIExplorer/GeolocationExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,15 @@ var GeolocationExample = React.createClass({

componentDidMount: function() {
navigator.geolocation.getCurrentPosition(
(initialPosition) => this.setState({initialPosition}),
(position) => {
var initialPosition = JSON.stringify(position);
this.setState({initialPosition});
},
(error) => alert(error.message),
{enableHighAccuracy: true, timeout: 20000, maximumAge: 1000}
);
this.watchID = navigator.geolocation.watchPosition((lastPosition) => {
this.watchID = navigator.geolocation.watchPosition((position) => {
var lastPosition = JSON.stringify(position);
this.setState({lastPosition});
});
},
Expand All @@ -67,11 +71,11 @@ var GeolocationExample = React.createClass({
<View>
<Text>
<Text style={styles.title}>Initial position: </Text>
{JSON.stringify(this.state.initialPosition)}
{this.state.initialPosition}
</Text>
<Text>
<Text style={styles.title}>Current position: </Text>
{JSON.stringify(this.state.lastPosition)}
{this.state.lastPosition}
</Text>
</View>
);
Expand Down
1 change: 1 addition & 0 deletions Examples/UIExplorer/ImageExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ var NetworkImageCallbackExample = React.createClass({
getInitialState: function() {
return {
events: [],
mountTime: new Date(),
};
},

Expand Down
25 changes: 18 additions & 7 deletions Examples/UIExplorer/LayoutEventsExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,30 @@ var {
View,
} = React;

type Layout = {
x: number;
y: number;
width: number;
height: number;
};

type LayoutEvent = {
nativeEvent: {
layout: {
x: number;
y: number;
width: number;
height: number;
};
layout: Layout,
};
};

type State = {
containerStyle?: { width: number },
extraText?: string,
imageLayout?: Layout,
textLayout?: Layout,
viewLayout?: Layout,
viewStyle: { margin: number },
};

var LayoutEventExample = React.createClass({
getInitialState: function() {
getInitialState(): State {
return {
viewStyle: {
margin: 20,
Expand Down
87 changes: 76 additions & 11 deletions Examples/UIExplorer/MapViewExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ var regionText = {
longitudeDelta: '0',
};

type MapRegion = {
latitude: number,
longitude: number,
latitudeDelta: number,
longitudeDelta: number,
};

type MapRegionInputState = {
region: MapRegion,
};

var MapRegionInput = React.createClass({

propTypes: {
Expand All @@ -43,7 +54,7 @@ var MapRegionInput = React.createClass({
onChange: React.PropTypes.func.isRequired,
},

getInitialState: function() {
getInitialState(): MapRegionInputState {
return {
region: {
latitude: 0,
Expand Down Expand Up @@ -135,19 +146,42 @@ var MapRegionInput = React.createClass({

_change: function() {
this.setState({
latitude: parseFloat(regionText.latitude),
longitude: parseFloat(regionText.longitude),
latitudeDelta: parseFloat(regionText.latitudeDelta),
longitudeDelta: parseFloat(regionText.longitudeDelta),
region: {
latitude: parseFloat(regionText.latitude),
longitude: parseFloat(regionText.longitude),
latitudeDelta: parseFloat(regionText.latitudeDelta),
longitudeDelta: parseFloat(regionText.longitudeDelta),
},
});
this.props.onChange(this.state.region);
},

});

type Annotations = Array<{
animateDrop?: boolean,
latitude: number,
longitude: number,
title?: string,
subtitle?: string,
hasLeftCallout?: boolean,
hasRightCallout?: boolean,
onLeftCalloutPress?: Function,
onRightCalloutPress?: Function,
tintColor?: string,
image?: any,
id?: string,
}>;
type MapViewExampleState = {
isFirstLoad: boolean,
mapRegion?: MapRegion,
mapRegionInput?: MapRegion,
annotations?: Annotations,
};

var MapViewExample = React.createClass({

getInitialState() {
getInitialState(): MapViewExampleState {
return {
isFirstLoad: true,
};
Expand All @@ -171,7 +205,7 @@ var MapViewExample = React.createClass({
);
},

_getAnnotations(region) {
_getAnnotations(region): Annotations {
return [{
longitude: region.longitude,
latitude: region.latitude,
Expand Down Expand Up @@ -205,9 +239,14 @@ var MapViewExample = React.createClass({

});

type CalloutMapViewExampleState = {
isFirstLoad: boolean,
annotations?: Annotations,
mapRegion?: MapRegion,
};
var CalloutMapViewExample = React.createClass({

getInitialState() {
getInitialState(): CalloutMapViewExampleState {
return {
isFirstLoad: true,
};
Expand Down Expand Up @@ -243,9 +282,14 @@ var CalloutMapViewExample = React.createClass({

});

type CustomPinColorMapViewExampleState = {
isFirstLoad: boolean,
annotations?: Annotations,
mapRegion?: MapRegion,
};
var CustomPinColorMapViewExample = React.createClass({

getInitialState() {
getInitialState(): CustomPinColorMapViewExampleState {
return {
isFirstLoad: true,
};
Expand Down Expand Up @@ -278,9 +322,14 @@ var CustomPinColorMapViewExample = React.createClass({

});

type CustomPinImageMapViewExampleState = {
isFirstLoad: boolean,
annotations?: Annotations,
mapRegion?: MapRegion,
};
var CustomPinImageMapViewExample = React.createClass({

getInitialState() {
getInitialState(): CustomPinImageMapViewExampleState {
return {
isFirstLoad: true,
};
Expand Down Expand Up @@ -313,9 +362,25 @@ var CustomPinImageMapViewExample = React.createClass({

});

type Overlays = Array<{
coordinates?: Array<{
latitude: number,
longitude: number,
}>,
lineWidth?: number,
strokeColor?: string,
fillColor?: string,
id?: string,
}>;
type CustomOverlayMapViewExampleState = {
isFirstLoad: boolean,
overlays?: Overlays,
annotations?: Annotations,
mapRegion?: MapRegion,
};
var CustomOverlayMapViewExample = React.createClass({

getInitialState() {
getInitialState(): CustomOverlayMapViewExampleState {
return {
isFirstLoad: true,
};
Expand Down
8 changes: 5 additions & 3 deletions Examples/UIExplorer/PanResponderExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* @flow-weak
* @flow weak
*/
'use strict';

Expand Down Expand Up @@ -79,15 +79,17 @@ var PanResponderExample = React.createClass({
},

_highlight: function() {
this.circle && this.circle.setNativeProps({
const circle = this.circle;
circle && circle.setNativeProps({
style: {
backgroundColor: processColor(CIRCLE_HIGHLIGHT_COLOR)
}
});
},

_unHighlight: function() {
this.circle && this.circle.setNativeProps({
const circle = this.circle;
circle && circle.setNativeProps({
style: {
backgroundColor: processColor(CIRCLE_COLOR)
}
Expand Down
2 changes: 1 addition & 1 deletion Examples/UIExplorer/PickerIOSExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ var PickerExample = React.createClass({
{CAR_MAKES_AND_MODELS[this.state.carMake].models.map(
(modelName, modelIndex) => (
<PickerItemIOS
key={this.state.carmake + '_' + modelIndex}
key={this.state.carMake + '_' + modelIndex}
value={modelIndex}
label={modelName}
/>
Expand Down
2 changes: 1 addition & 1 deletion Examples/UIExplorer/UIExplorerListBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class UIExplorerListBase extends React.Component {
search(text: mixed): void {
this.props.search && this.props.search(text);

var regex = new RegExp(text, 'i');
var regex = new RegExp(String(text), 'i');
var filter = (component) => regex.test(component.title);

this.setState({
Expand Down
3 changes: 2 additions & 1 deletion Examples/UIExplorer/XHRExampleHeaders.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* @noflow
*/
'use strict';

Expand Down Expand Up @@ -113,4 +114,4 @@ var styles = StyleSheet.create({
},
});

module.exports = XHRExampleHeaders;
module.exports = XHRExampleHeaders;
9 changes: 8 additions & 1 deletion IntegrationTests/AppEventsTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,15 @@ var deepDiffer = require('deepDiffer');

var TEST_PAYLOAD = {foo: 'bar'};

type AppEvent = { data: Object, ts: number, };
type State = {
sent: 'none' | AppEvent,
received: 'none' | AppEvent,
elapsed?: string,
};

var AppEventsTest = React.createClass({
getInitialState: function() {
getInitialState(): State {
return {sent: 'none', received: 'none'};
},
componentDidMount: function() {
Expand Down
4 changes: 3 additions & 1 deletion IntegrationTests/IntegrationTestsApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ TESTS.forEach(
// Modules required for integration tests
require('LoggingTestModule');

type Test = any;

var IntegrationTestsApp = React.createClass({
getInitialState: function() {
return {
test: null,
test: (null: ?Test),
};
},
render: function() {
Expand Down
33 changes: 26 additions & 7 deletions IntegrationTests/LayoutEventsTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,38 @@ function debug() {
// console.log.apply(null, arguments);
}

type Layout = {
x: number;
y: number;
width: number;
height: number;
};
type LayoutEvent = {
nativeEvent: {
layout: {
x: number;
y: number;
width: number;
height: number;
};
layout: Layout;
};
};
type Style = {
margin?: number,
padding?: number,
borderColor?: string,
borderWidth?: number,
backgroundColor?: string,
width?: number,
};

type State = {
didAnimation: boolean,
extraText?: string,
imageLayout?: Layout,
textLayout?: Layout,
viewLayout?: Layout,
viewStyle?: Style,
containerStyle?: Style,
};

var LayoutEventsTest = React.createClass({
getInitialState: function() {
getInitialState(): State {
return {
didAnimation: false,
};
Expand Down
4 changes: 2 additions & 2 deletions Libraries/Components/Navigation/NavigatorIOS.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ type State = {
fromIndex: number;
toIndex: number;
makingNavigatorRequest: boolean;
updatingAllIndicesAtOrBeyond: number;
updatingAllIndicesAtOrBeyond: ?number;
}

type Event = Object;
Expand Down Expand Up @@ -592,7 +592,7 @@ var NavigatorIOS = React.createClass({

_routeToStackItem: function(route: Route, i: number) {
var Component = route.component;
var shouldUpdateChild = this.state.updatingAllIndicesAtOrBeyond !== null &&
var shouldUpdateChild = this.state.updatingAllIndicesAtOrBeyond != null &&
this.state.updatingAllIndicesAtOrBeyond >= i;

return (
Expand Down
Loading

0 comments on commit 892dd5b

Please sign in to comment.