Fix or suppress errors in react-native

Reviewed By: jeffmo

Differential Revision: D3209973

fb-gh-sync-id: bdc9b4afc0b187b1b16fa6bfb1c34adb4089ab81
fbshipit-source-id: bdc9b4afc0b187b1b16fa6bfb1c34adb4089ab81
This commit is contained in:
glevi@fb.com 2016-04-21 19:46:36 -07:00 committed by Facebook Github Bot 0
parent 5a93877673
commit 91d4a093ea
13 changed files with 86 additions and 70 deletions

View File

@ -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

View File

@ -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 || {}]
}));
}

View File

@ -64,6 +64,11 @@ type Props = {
renderScene: NavigationSceneRenderer,
};
type DefaultProps = {
direction: NavigationGestureDirection,
renderOverlay: ?NavigationSceneRenderer,
};
/**
* A controlled navigation view that renders a stack of cards.
*
@ -78,7 +83,7 @@ type Props = {
* +-+ |
* +------------+
*/
class NavigationCardStack extends React.Component {
class NavigationCardStack extends React.Component<DefaultProps, Props, void> {
_renderScene : NavigationSceneRenderer;
static propTypes = {
@ -88,7 +93,7 @@ class NavigationCardStack extends React.Component {
renderScene: PropTypes.func.isRequired,
};
static defaultProps = {
static defaultProps: DefaultProps = {
direction: Directions.HORIZONTAL,
renderOverlay: emptyFunction.thatReturnsNull,
};
@ -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,
@ -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]}
/>
);

View File

@ -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;

View File

@ -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;
@ -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;

View File

@ -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;
@ -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;

View File

@ -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.
@ -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: {
@ -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(
@ -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;
@ -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.

View File

@ -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;
@ -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',

View File

@ -16,7 +16,7 @@ var NavigationRootContainer = require('NavigationRootContainer');
function createNavigationContainer(
Component: ReactClass<any>,
): ReactClass {
): ReactClass & Object {
class NavigationComponent extends React.Component {
render() {
return (

View File

@ -95,6 +95,9 @@ class NavigationRootContainer extends React.Component<any, Props, State> {
onNavigate: PropTypes.func,
};
static getBackAction = getBackAction;
constructor(props: Props) {
super(props);
@ -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 {
@ -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;
@ -164,6 +168,7 @@ class NavigationRootContainer extends React.Component<any, Props, State> {
return false;
}
this.setState({
// $FlowFixMe - navState is missing properties :(
navState,
});
@ -183,6 +188,4 @@ class NavigationRootContainer extends React.Component<any, Props, State> {
}
}
NavigationRootContainer.getBackAction = getBackAction;
module.exports = NavigationRootContainer;

View File

@ -112,4 +112,3 @@ export type NavigationSceneRenderer = (
export type NavigationStyleInterpolator = (
props: NavigationSceneRendererProps,
) => Object;

View File

@ -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);

View File

@ -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'),
},