Skip to content

Commit

Permalink
Fix or suppress errors in react-native
Browse files Browse the repository at this point in the history
Reviewed By: jeffmo

Differential Revision: D3209973

fb-gh-sync-id: bdc9b4afc0b187b1b16fa6bfb1c34adb4089ab81
fbshipit-source-id: bdc9b4afc0b187b1b16fa6bfb1c34adb4089ab81
  • Loading branch information
gabelevi authored and Facebook Github Bot 0 committed Apr 22, 2016
1 parent 5a93877 commit 91d4a09
Show file tree
Hide file tree
Showing 13 changed files with 86 additions and 70 deletions.
2 changes: 0 additions & 2 deletions .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
# Ignore react and fbjs where there are overlaps, but don't ignore
# anything that react-native relies on
.*/node_modules/fbjs/lib/Map.js
.*/node_modules/fbjs/lib/fetch.js
.*/node_modules/fbjs/lib/ExecutionEnvironment.js
.*/node_modules/fbjs/lib/ErrorUtils.js

# Flow has a built-in definition for the 'react' module which we prefer to use
Expand Down
1 change: 1 addition & 0 deletions Libraries/Components/MapView/MapView.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ const MapView = React.createClass({
}
var viewIndex = children.length;
children.push(React.cloneElement(view, {
// $FlowFixMe - An array of styles should be fine
style: [styles.annotationView, view.props.style || {}]
}));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ type Props = {
renderScene: NavigationSceneRenderer,
};

type DefaultProps = {
direction: NavigationGestureDirection,
renderOverlay: ?NavigationSceneRenderer,
};

/**
* A controlled navigation view that renders a stack of cards.
*
Expand All @@ -78,7 +83,7 @@ type Props = {
* +-+ |
* +------------+
*/
class NavigationCardStack extends React.Component {
class NavigationCardStack extends React.Component<DefaultProps, Props, void> {
_renderScene : NavigationSceneRenderer;

static propTypes = {
Expand All @@ -88,7 +93,7 @@ class NavigationCardStack extends React.Component {
renderScene: PropTypes.func.isRequired,
};

static defaultProps = {
static defaultProps: DefaultProps = {
direction: Directions.HORIZONTAL,
renderOverlay: emptyFunction.thatReturnsNull,
};
Expand All @@ -101,7 +106,7 @@ class NavigationCardStack extends React.Component {
this._renderScene = this._renderScene.bind(this);
}

shouldComponentUpdate(nextProps: Object, nextState: Object): boolean {
shouldComponentUpdate(nextProps: Object, nextState: void): boolean {
return ReactComponentWithPureRenderMixin.shouldComponentUpdate.call(
this,
nextProps,
Expand All @@ -115,6 +120,7 @@ class NavigationCardStack extends React.Component {
navigationState={this.props.navigationState}
renderOverlay={this.props.renderOverlay}
renderScene={this._renderScene}
// $FlowFixMe - style should be declared
style={[styles.animatedView, this.props.style]}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,10 @@ const styles = StyleSheet.create({
},
});

NavigationHeader = NavigationContainer.create(NavigationHeader);
const NavigationHeaderContainer = NavigationContainer.create(NavigationHeader);

NavigationHeader.HEIGHT = APPBAR_HEIGHT + STATUSBAR_HEIGHT;
NavigationHeader.Title = NavigationHeaderTitle;
NavigationHeader.BackButton = NavigationHeaderBackButton;
NavigationHeaderContainer.HEIGHT = APPBAR_HEIGHT + STATUSBAR_HEIGHT;
NavigationHeaderContainer.Title = NavigationHeaderTitle;
NavigationHeaderContainer.BackButton = NavigationHeaderBackButton;

module.exports = NavigationHeader;
module.exports = NavigationHeaderContainer;
30 changes: 18 additions & 12 deletions Libraries/Experimental/Incremental.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,31 @@ export type Props = {
* Tags instances and associated tasks for easier debugging.
*/
name: string;
children: any;
children?: any;
};
class Incremental extends React.Component {
type DefaultProps = {
name: string,
};
type State = {
doIncrementalRender: boolean,
};
class Incremental extends React.Component<DefaultProps, Props, State> {
props: Props;
state: {
doIncrementalRender: boolean;
};
state: State;
context: Context;
_incrementId: number;
_mounted: boolean;
_rendered: boolean;

static defaultProps = {
name: '',
};

static contextTypes = {
incrementalGroup: React.PropTypes.object,
incrementalGroupEnabled: React.PropTypes.bool,
};

constructor(props: Props, context: Context) {
super(props, context);
this._mounted = false;
Expand Down Expand Up @@ -159,13 +172,6 @@ class Incremental extends React.Component {
this._mounted = false;
}
}
Incremental.defaultProps = {
name: '',
};
Incremental.contextTypes = {
incrementalGroup: React.PropTypes.object,
incrementalGroupEnabled: React.PropTypes.bool,
};

export type Context = {
incrementalGroupEnabled: boolean;
Expand Down
34 changes: 18 additions & 16 deletions Libraries/Experimental/IncrementalPresenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,29 @@ import type {Context} from 'Incremental';
*/
type Props = {
name: string;
disabled: boolean;
onDone: () => void;
onLayout: (event: Object) => void;
style: mixed;
children: any;
disabled?: boolean;
onDone?: () => void;
onLayout?: (event: Object) => void;
style?: mixed;
children?: any;
}
class IncrementalPresenter extends React.Component {
props: Props;
context: Context;
_isDone: boolean;

static propTypes = {
name: React.PropTypes.string,
disabled: React.PropTypes.bool,
onDone: React.PropTypes.func,
onLayout: React.PropTypes.func,
style: View.propTypes.style,
};
static contextTypes = {
incrementalGroup: React.PropTypes.object,
incrementalGroupEnabled: React.PropTypes.bool,
};

constructor(props: Props, context: Context) {
super(props, context);
this._isDone = false;
Expand Down Expand Up @@ -80,16 +93,5 @@ class IncrementalPresenter extends React.Component {
);
}
}
IncrementalPresenter.propTypes = {
name: React.PropTypes.string,
disabled: React.PropTypes.bool,
onDone: React.PropTypes.func,
onLayout: React.PropTypes.func,
style: View.propTypes.style,
};
IncrementalPresenter.contextTypes = {
incrementalGroup: React.PropTypes.object,
incrementalGroupEnabled: React.PropTypes.bool,
};

module.exports = IncrementalPresenter;
27 changes: 14 additions & 13 deletions Libraries/Experimental/WindowedListView.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ type Props = {
* return a row.
*/
renderRow: (
data: mixed, sectionIdx: number, rowIdx: number, key: string
data: mixed, sectionIdx: number, rowIdx: number, key?: string
) => ?ReactElement;
/**
* Rendered when the list is scrolled faster than rows can be rendered.
Expand Down Expand Up @@ -160,16 +160,6 @@ type Props = {
*/
onMountedRowsWillChange: (firstIdx: number, count: number) => void;
};
const defaultProps = {
enableDangerousRecycling: false,
initialNumToRender: 10,
maxNumToRender: 30,
numToRenderAhead: 10,
viewablePercentThreshold: 50,
renderScrollComponent: (props) => <ScrollView {...props} />,
disableIncrementalRendering: false,
recomputeRowsBatchingPeriod: 100,
};
class WindowedListView extends React.Component {
props: Props;
state: {
Expand All @@ -189,6 +179,18 @@ class WindowedListView extends React.Component {
_viewableRows: Array<number> = [];
_cellsInProgress: Set<number> = new Set();
_scrollRef: ?Object;

static defaultProps = {
enableDangerousRecycling: false,
initialNumToRender: 10,
maxNumToRender: 30,
numToRenderAhead: 10,
viewablePercentThreshold: 50,
renderScrollComponent: (props) => <ScrollView {...props} />,
disableIncrementalRendering: false,
recomputeRowsBatchingPeriod: 100,
};

constructor(props: Props) {
super(props);
invariant(
Expand Down Expand Up @@ -495,7 +497,6 @@ class WindowedListView extends React.Component {
);
}
}
WindowedListView.defaultProps = defaultProps;

// performance testing id, unique for each component mount cycle
let g_perf_update_id = 0;
Expand Down Expand Up @@ -530,7 +531,7 @@ type CellProps = {
* Updates the parent with the latest layout. Only called when incremental rendering is done and triggers the parent
* to re-render this row with includeInLayout true.
*/
onNewLayout: (params: {rowIndex: number, layout: ?Object}) => void;
onNewLayout: (params: {rowIndex: number, layout: Object}) => void;
/**
* Used to track when rendering is in progress so the parent can avoid wastedful re-renders that are just going to be
* invalidated once the cell finishes.
Expand Down
24 changes: 12 additions & 12 deletions Libraries/Modal/Modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@ const RCTModalHostView = requireNativeComponent('RCTModalHostView', null);
* configureScene property.
*/
class Modal extends React.Component {
static propTypes = {
animated: PropTypes.bool,
transparent: PropTypes.bool,
visible: PropTypes.bool,
onRequestClose: Platform.OS === 'android' ? PropTypes.func.isRequired : PropTypes.func,
onShow: PropTypes.func,
};

static defaultProps = {
visible: true,
};

render(): ?ReactElement {
if (this.props.visible === false) {
return null;
Expand Down Expand Up @@ -65,18 +77,6 @@ class Modal extends React.Component {
}
}

Modal.propTypes = {
animated: PropTypes.bool,
transparent: PropTypes.bool,
visible: PropTypes.bool,
onRequestClose: Platform.OS === 'android' ? PropTypes.func.isRequired : PropTypes.func,
onShow: PropTypes.func,
};

Modal.defaultProps = {
visible: true,
};

const styles = StyleSheet.create({
modal: {
position: 'absolute',
Expand Down
2 changes: 1 addition & 1 deletion Libraries/NavigationExperimental/NavigationContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var NavigationRootContainer = require('NavigationRootContainer');

function createNavigationContainer(
Component: ReactClass<any>,
): ReactClass {
): ReactClass & Object {
class NavigationComponent extends React.Component {
render() {
return (
Expand Down
11 changes: 7 additions & 4 deletions Libraries/NavigationExperimental/NavigationRootContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ class NavigationRootContainer extends React.Component<any, Props, State> {
onNavigate: PropTypes.func,
};


static getBackAction = getBackAction;

constructor(props: Props) {
super(props);

Expand All @@ -108,8 +111,8 @@ class NavigationRootContainer extends React.Component<any, Props, State> {
}

componentWillMount(): void {
this.handleNavigation = this.handleNavigation.bind(this);
this._handleOpenURLEvent = this._handleOpenURLEvent.bind(this);
(this: any).handleNavigation = this.handleNavigation.bind(this);
(this: any)._handleOpenURLEvent = this._handleOpenURLEvent.bind(this);
}

componentDidMount(): void {
Expand All @@ -121,6 +124,7 @@ class NavigationRootContainer extends React.Component<any, Props, State> {
AsyncStorage.getItem(this.props.persistenceKey, (err, storedString) => {
if (err || !storedString) {
this.setState({
// $FlowFixMe - navState is missing properties :(
navState: this.props.reducer(null, this.props.initialAction),
});
return;
Expand Down Expand Up @@ -164,6 +168,7 @@ class NavigationRootContainer extends React.Component<any, Props, State> {
return false;
}
this.setState({
// $FlowFixMe - navState is missing properties :(
navState,
});

Expand All @@ -183,6 +188,4 @@ class NavigationRootContainer extends React.Component<any, Props, State> {
}
}

NavigationRootContainer.getBackAction = getBackAction;

module.exports = NavigationRootContainer;
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,3 @@ export type NavigationSceneRenderer = (
export type NavigationStyleInterpolator = (
props: NavigationSceneRendererProps,
) => Object;

1 change: 1 addition & 0 deletions Libraries/ReactIOS/YellowBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ class YellowBox extends React.Component {
warningMap: Map;
};
_listener: ?EmitterSubscription;
dismissWarning: (warning: ?string) => void;

constructor(props: mixed, context: mixed) {
super(props, context);
Expand Down
1 change: 0 additions & 1 deletion Libraries/react-native/react-native.js.flow
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ var ReactNative = Object.assign(Object.create(require('react')), {
TestModule: require('NativeModules').TestModule,
TestUtils: undefined,
batchedUpdates: require('ReactUpdates').batchedUpdates,
cloneWithProps: require('cloneWithProps'),
createFragment: require('ReactFragment').create,
update: require('update'),
},
Expand Down

0 comments on commit 91d4a09

Please sign in to comment.