mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-28 20:25:33 +08:00
Codemod to 1.7.0
Differential Revision: D5763302 fbshipit-source-id: a91ca1786c7ac8eb9aa3dd43555a7a223dc6f9cf
This commit is contained in:
committed by
Facebook Github Bot
parent
888c6e7eac
commit
70c6700be8
@@ -502,11 +502,7 @@ var ListView = createReactClass({
|
||||
adjacentRowHighlighted,
|
||||
);
|
||||
if (separator) {
|
||||
bodyComponents.push(
|
||||
<View key={'s_' + comboID}>
|
||||
{separator}
|
||||
</View>,
|
||||
);
|
||||
bodyComponents.push(<View key={'s_' + comboID}>{separator}</View>);
|
||||
totalIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,11 +204,12 @@ class MetroListView extends React.Component<Props, $FlowFixMeState> {
|
||||
);
|
||||
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. */
|
||||
<this.props.SeparatorComponent key={sID + rID} />;
|
||||
<this.props.SeparatorComponent key={sID + rID} />
|
||||
);
|
||||
}
|
||||
|
||||
module.exports = MetroListView;
|
||||
|
||||
@@ -112,8 +112,7 @@ class ViewabilityHelper {
|
||||
: itemVisiblePercentThreshold;
|
||||
invariant(
|
||||
viewablePercentThreshold != null &&
|
||||
itemVisiblePercentThreshold !=
|
||||
null !==
|
||||
(itemVisiblePercentThreshold != null) !==
|
||||
(viewAreaCoveragePercentThreshold != null),
|
||||
'Must set exactly one of itemVisiblePercentThreshold or viewAreaCoveragePercentThreshold',
|
||||
);
|
||||
|
||||
@@ -605,9 +605,12 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
||||
if (stickyIndicesFromProps.has(0)) {
|
||||
stickyHeaderIndices.push(0);
|
||||
}
|
||||
const element = React.isValidElement(ListHeaderComponent)
|
||||
? ListHeaderComponent // $FlowFixMe
|
||||
: <ListHeaderComponent />;
|
||||
const element = React.isValidElement(ListHeaderComponent) ? (
|
||||
ListHeaderComponent
|
||||
) : (
|
||||
// $FlowFixMe
|
||||
<ListHeaderComponent />
|
||||
);
|
||||
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<Props, State> {
|
||||
);
|
||||
}
|
||||
} else if (ListEmptyComponent) {
|
||||
const element = React.isValidElement(ListEmptyComponent)
|
||||
? ListEmptyComponent // $FlowFixMe
|
||||
: <ListEmptyComponent />;
|
||||
const element = React.isValidElement(ListEmptyComponent) ? (
|
||||
ListEmptyComponent
|
||||
) : (
|
||||
// $FlowFixMe
|
||||
<ListEmptyComponent />
|
||||
);
|
||||
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<Props, State> {
|
||||
);
|
||||
}
|
||||
if (ListFooterComponent) {
|
||||
const element = React.isValidElement(ListFooterComponent)
|
||||
? ListFooterComponent // $FlowFixMe
|
||||
: <ListFooterComponent />;
|
||||
const element = React.isValidElement(ListFooterComponent) ? (
|
||||
ListFooterComponent
|
||||
) : (
|
||||
// $FlowFixMe
|
||||
<ListFooterComponent />
|
||||
);
|
||||
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<Props, State> {
|
||||
borderColor: 'blue',
|
||||
borderWidth: 1,
|
||||
}}>
|
||||
{framesInLayout.map((f, ii) =>
|
||||
{framesInLayout.map((f, ii) => (
|
||||
<View
|
||||
key={'f' + ii}
|
||||
style={{
|
||||
@@ -952,8 +961,8 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
||||
height: f.length * normalize,
|
||||
backgroundColor: 'orange',
|
||||
}}
|
||||
/>,
|
||||
)}
|
||||
/>
|
||||
))}
|
||||
<View
|
||||
style={{
|
||||
...baseStyle,
|
||||
@@ -1335,9 +1344,9 @@ class CellRenderer extends React.Component<
|
||||
: this.props.onLayout;
|
||||
// NOTE: that when this is a sticky header, `onLayout` will get automatically extracted and
|
||||
// called explicitly by `ScrollViewStickyHeader`.
|
||||
const itemSeparator =
|
||||
ItemSeparatorComponent &&
|
||||
<ItemSeparatorComponent {...this.state.separatorProps} />;
|
||||
const itemSeparator = ItemSeparatorComponent && (
|
||||
<ItemSeparatorComponent {...this.state.separatorProps} />
|
||||
);
|
||||
const cellStyle = inversionStyle
|
||||
? horizontal
|
||||
? [{flexDirection: 'row-reverse'}, inversionStyle]
|
||||
|
||||
@@ -484,19 +484,21 @@ class ItemWithSeparator extends React.Component<
|
||||
section,
|
||||
separators: this._separators,
|
||||
});
|
||||
const leadingSeparator =
|
||||
LeadingSeparatorComponent &&
|
||||
<LeadingSeparatorComponent {...this.state.leadingSeparatorProps} />;
|
||||
const separator =
|
||||
SeparatorComponent &&
|
||||
<SeparatorComponent {...this.state.separatorProps} />;
|
||||
return leadingSeparator || separator
|
||||
? <View>
|
||||
{leadingSeparator}
|
||||
{element}
|
||||
{separator}
|
||||
</View>
|
||||
: element;
|
||||
const leadingSeparator = LeadingSeparatorComponent && (
|
||||
<LeadingSeparatorComponent {...this.state.leadingSeparatorProps} />
|
||||
);
|
||||
const separator = SeparatorComponent && (
|
||||
<SeparatorComponent {...this.state.separatorProps} />
|
||||
);
|
||||
return leadingSeparator || separator ? (
|
||||
<View>
|
||||
{leadingSeparator}
|
||||
{element}
|
||||
{separator}
|
||||
</View>
|
||||
) : (
|
||||
element
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -60,13 +60,14 @@ module.exports = {
|
||||
];
|
||||
return (
|
||||
<FlatList
|
||||
renderItem={info =>
|
||||
renderItem={info => (
|
||||
<span>
|
||||
{
|
||||
// $FlowExpectedError - bad widgetCount type 6, should be Object
|
||||
info.item.widget.missingProp
|
||||
}
|
||||
</span>}
|
||||
</span>
|
||||
)}
|
||||
data={data}
|
||||
/>
|
||||
);
|
||||
|
||||
@@ -19,8 +19,9 @@ function renderMyListItem(info: {item: {title: string}, index: number}) {
|
||||
return <span />;
|
||||
}
|
||||
|
||||
const renderMyHeader = ({section}: {section: {fooNumber: number} & Object}) =>
|
||||
<span />;
|
||||
const renderMyHeader = ({section}: {section: {fooNumber: number} & Object}) => (
|
||||
<span />
|
||||
);
|
||||
|
||||
module.exports = {
|
||||
testGoodDataWithGoodItem() {
|
||||
|
||||
@@ -40,20 +40,23 @@ describe('SectionList', () => {
|
||||
const component = ReactTestRenderer.create(
|
||||
<SectionList
|
||||
initialNumToRender={Infinity}
|
||||
ItemSeparatorComponent={props =>
|
||||
<defaultItemSeparator v={propStr(props)} />}
|
||||
ItemSeparatorComponent={props => (
|
||||
<defaultItemSeparator v={propStr(props)} />
|
||||
)}
|
||||
ListEmptyComponent={props => <empty v={propStr(props)} />}
|
||||
ListFooterComponent={props => <footer v={propStr(props)} />}
|
||||
ListHeaderComponent={props => <header v={propStr(props)} />}
|
||||
SectionSeparatorComponent={props =>
|
||||
<sectionSeparator v={propStr(props)} />}
|
||||
SectionSeparatorComponent={props => (
|
||||
<sectionSeparator v={propStr(props)} />
|
||||
)}
|
||||
sections={[
|
||||
{
|
||||
renderItem: props => <itemForSection1 v={propStr(props)} />,
|
||||
key: 's1',
|
||||
keyExtractor: (item, index) => item.id,
|
||||
ItemSeparatorComponent: props =>
|
||||
<itemSeparatorForSection1 v={propStr(props)} />,
|
||||
ItemSeparatorComponent: props => (
|
||||
<itemSeparatorForSection1 v={propStr(props)} />
|
||||
),
|
||||
data: [{id: 'i1s1'}, {id: 'i2s1'}],
|
||||
},
|
||||
{
|
||||
|
||||
@@ -140,7 +140,7 @@ describe('VirtualizedList', () => {
|
||||
const component = ReactTestRenderer.create(
|
||||
<VirtualizedList
|
||||
data={[{key: 'outer0'}, {key: 'outer1'}]}
|
||||
renderItem={outerInfo =>
|
||||
renderItem={outerInfo => (
|
||||
<VirtualizedList
|
||||
data={[
|
||||
{key: outerInfo.item.key + ':inner0'},
|
||||
@@ -152,7 +152,8 @@ describe('VirtualizedList', () => {
|
||||
}}
|
||||
getItem={(data, index) => data[index]}
|
||||
getItemCount={data => data.length}
|
||||
/>}
|
||||
/>
|
||||
)}
|
||||
getItem={(data, index) => data[index]}
|
||||
getItemCount={data => data.length}
|
||||
/>,
|
||||
|
||||
Reference in New Issue
Block a user