From 70c6700be855d932800e4d5975a0bd1730049c33 Mon Sep 17 00:00:00 2001 From: Christopher Chedeau Date: Tue, 26 Sep 2017 23:33:30 -0700 Subject: [PATCH] Codemod to 1.7.0 Differential Revision: D5763302 fbshipit-source-id: a91ca1786c7ac8eb9aa3dd43555a7a223dc6f9cf --- Libraries/Lists/ListView/ListView.js | 6 +-- Libraries/Lists/MetroListView.js | 5 ++- Libraries/Lists/ViewabilityHelper.js | 3 +- Libraries/Lists/VirtualizedList.js | 39 +++++++++++------- Libraries/Lists/VirtualizedSectionList.js | 28 +++++++------ .../Lists/__flowtests__/FlatList-flowtest.js | 5 ++- .../__flowtests__/SectionList-flowtest.js | 5 ++- Libraries/Lists/__tests__/SectionList-test.js | 15 ++++--- .../Lists/__tests__/VirtualizedList-test.js | 5 ++- Libraries/ReactNative/AppContainer.js | 34 +++++++--------- Libraries/ReactNative/YellowBox.js | 40 ++++++++----------- RNTester/js/CameraRollExample.js | 24 +++-------- RNTester/js/CheckBoxExample.js | 8 +--- RNTester/js/WebSocketExample.js | 20 ++-------- 14 files changed, 106 insertions(+), 131 deletions(-) diff --git a/Libraries/Lists/ListView/ListView.js b/Libraries/Lists/ListView/ListView.js index 5273cc1cb..bb54f1b3d 100644 --- a/Libraries/Lists/ListView/ListView.js +++ b/Libraries/Lists/ListView/ListView.js @@ -502,11 +502,7 @@ var ListView = createReactClass({ adjacentRowHighlighted, ); if (separator) { - bodyComponents.push( - - {separator} - , - ); + bodyComponents.push({separator}); totalIndex++; } } diff --git a/Libraries/Lists/MetroListView.js b/Libraries/Lists/MetroListView.js index d168428ce..dde23a226 100644 --- a/Libraries/Lists/MetroListView.js +++ b/Libraries/Lists/MetroListView.js @@ -204,11 +204,12 @@ class MetroListView extends React.Component { ); return renderSectionHeader({section}); }; - _renderSeparator = (sID, rID) => + _renderSeparator = (sID, rID) => ( /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This comment * suppresses an error when upgrading Flow's support for React. To see the * error delete this comment and run Flow. */ - ; + + ); } module.exports = MetroListView; diff --git a/Libraries/Lists/ViewabilityHelper.js b/Libraries/Lists/ViewabilityHelper.js index 370c20fec..3742e607d 100644 --- a/Libraries/Lists/ViewabilityHelper.js +++ b/Libraries/Lists/ViewabilityHelper.js @@ -112,8 +112,7 @@ class ViewabilityHelper { : itemVisiblePercentThreshold; invariant( viewablePercentThreshold != null && - itemVisiblePercentThreshold != - null !== + (itemVisiblePercentThreshold != null) !== (viewAreaCoveragePercentThreshold != null), 'Must set exactly one of itemVisiblePercentThreshold or viewAreaCoveragePercentThreshold', ); diff --git a/Libraries/Lists/VirtualizedList.js b/Libraries/Lists/VirtualizedList.js index eaedc0a2d..9b0e14ffa 100644 --- a/Libraries/Lists/VirtualizedList.js +++ b/Libraries/Lists/VirtualizedList.js @@ -605,9 +605,12 @@ class VirtualizedList extends React.PureComponent { if (stickyIndicesFromProps.has(0)) { stickyHeaderIndices.push(0); } - const element = React.isValidElement(ListHeaderComponent) - ? ListHeaderComponent // $FlowFixMe - : ; + const element = React.isValidElement(ListHeaderComponent) ? ( + ListHeaderComponent + ) : ( + // $FlowFixMe + + ); cells.push( /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This * comment suppresses an error when upgrading Flow's support for React. @@ -713,9 +716,12 @@ class VirtualizedList extends React.PureComponent { ); } } else if (ListEmptyComponent) { - const element = React.isValidElement(ListEmptyComponent) - ? ListEmptyComponent // $FlowFixMe - : ; + const element = React.isValidElement(ListEmptyComponent) ? ( + ListEmptyComponent + ) : ( + // $FlowFixMe + + ); cells.push( /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This * comment suppresses an error when upgrading Flow's support for React. @@ -729,9 +735,12 @@ class VirtualizedList extends React.PureComponent { ); } if (ListFooterComponent) { - const element = React.isValidElement(ListFooterComponent) - ? ListFooterComponent // $FlowFixMe - : ; + const element = React.isValidElement(ListFooterComponent) ? ( + ListFooterComponent + ) : ( + // $FlowFixMe + + ); cells.push( /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This * comment suppresses an error when upgrading Flow's support for React. @@ -942,7 +951,7 @@ class VirtualizedList extends React.PureComponent { borderColor: 'blue', borderWidth: 1, }}> - {framesInLayout.map((f, ii) => + {framesInLayout.map((f, ii) => ( { height: f.length * normalize, backgroundColor: 'orange', }} - />, - )} + /> + ))} ; + const itemSeparator = ItemSeparatorComponent && ( + + ); const cellStyle = inversionStyle ? horizontal ? [{flexDirection: 'row-reverse'}, inversionStyle] diff --git a/Libraries/Lists/VirtualizedSectionList.js b/Libraries/Lists/VirtualizedSectionList.js index 1db79c5c6..ca3a87082 100644 --- a/Libraries/Lists/VirtualizedSectionList.js +++ b/Libraries/Lists/VirtualizedSectionList.js @@ -484,19 +484,21 @@ class ItemWithSeparator extends React.Component< section, separators: this._separators, }); - const leadingSeparator = - LeadingSeparatorComponent && - ; - const separator = - SeparatorComponent && - ; - return leadingSeparator || separator - ? - {leadingSeparator} - {element} - {separator} - - : element; + const leadingSeparator = LeadingSeparatorComponent && ( + + ); + const separator = SeparatorComponent && ( + + ); + return leadingSeparator || separator ? ( + + {leadingSeparator} + {element} + {separator} + + ) : ( + element + ); } } diff --git a/Libraries/Lists/__flowtests__/FlatList-flowtest.js b/Libraries/Lists/__flowtests__/FlatList-flowtest.js index 02d744f67..3fe757b63 100644 --- a/Libraries/Lists/__flowtests__/FlatList-flowtest.js +++ b/Libraries/Lists/__flowtests__/FlatList-flowtest.js @@ -60,13 +60,14 @@ module.exports = { ]; return ( + renderItem={info => ( { // $FlowExpectedError - bad widgetCount type 6, should be Object info.item.widget.missingProp } - } + + )} data={data} /> ); diff --git a/Libraries/Lists/__flowtests__/SectionList-flowtest.js b/Libraries/Lists/__flowtests__/SectionList-flowtest.js index dc6be3c46..b452f736a 100644 --- a/Libraries/Lists/__flowtests__/SectionList-flowtest.js +++ b/Libraries/Lists/__flowtests__/SectionList-flowtest.js @@ -19,8 +19,9 @@ function renderMyListItem(info: {item: {title: string}, index: number}) { return ; } -const renderMyHeader = ({section}: {section: {fooNumber: number} & Object}) => - ; +const renderMyHeader = ({section}: {section: {fooNumber: number} & Object}) => ( + +); module.exports = { testGoodDataWithGoodItem() { diff --git a/Libraries/Lists/__tests__/SectionList-test.js b/Libraries/Lists/__tests__/SectionList-test.js index 301c9de65..8acc1621e 100644 --- a/Libraries/Lists/__tests__/SectionList-test.js +++ b/Libraries/Lists/__tests__/SectionList-test.js @@ -40,20 +40,23 @@ describe('SectionList', () => { const component = ReactTestRenderer.create( - } + ItemSeparatorComponent={props => ( + + )} ListEmptyComponent={props => } ListFooterComponent={props =>