mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-23 21:25:13 +08:00
SwipeableFlatList, SwipeableQuickActions: Remove PropTypes (#21384)
Summary: Part of: https://github.com/facebook/react-native/issues/21342 This PR removes the prop types for the components `SwipeableFlatList` and `SwipeableQuickActions`. The props for `SwipeableFlatList` have been left as not $ReadOnly, because it needs the types in `Libraries/Lists/*` to also be cleaned up. A todo notice has been added. Pull Request resolved: https://github.com/facebook/react-native/pull/21384 Differential Revision: D10099694 Pulled By: TheSavior fbshipit-source-id: 424b900942c9a7889b664f351f79abee55923430
This commit is contained in:
committed by
Facebook Github Bot
parent
16f06bcb80
commit
9104b04261
@@ -17,23 +17,31 @@ const React = require('React');
|
||||
const SwipeableRow = require('SwipeableRow');
|
||||
const FlatList = require('FlatList');
|
||||
|
||||
// TODO: Make this $ReadOnly and Exact. Will require doing the same to the props in
|
||||
// Libraries/Lists/*
|
||||
type SwipableListProps = {
|
||||
/**
|
||||
* To alert the user that swiping is possible, the first row can bounce
|
||||
* on component mount.
|
||||
*/
|
||||
bounceFirstRowOnMount: boolean,
|
||||
// Maximum distance to open to after a swipe
|
||||
|
||||
/**
|
||||
* Maximum distance to open to after a swipe
|
||||
*/
|
||||
maxSwipeDistance: number | (Object => number),
|
||||
// Callback method to render the view that will be unveiled on swipe
|
||||
|
||||
/**
|
||||
* Callback method to render the view that will be unveiled on swipe
|
||||
*/
|
||||
renderQuickActions: renderItemType,
|
||||
};
|
||||
|
||||
type Props<ItemT> = SwipableListProps & FlatListProps<ItemT>;
|
||||
|
||||
type State = {
|
||||
type State = {|
|
||||
openRowKey: ?string,
|
||||
};
|
||||
|};
|
||||
|
||||
/**
|
||||
* A container component that renders multiple SwipeableRow's in a FlatList
|
||||
@@ -53,29 +61,9 @@ type State = {
|
||||
*/
|
||||
|
||||
class SwipeableFlatList<ItemT> extends React.Component<Props<ItemT>, State> {
|
||||
props: Props<ItemT>;
|
||||
state: State;
|
||||
|
||||
_flatListRef: ?FlatList<ItemT> = null;
|
||||
_shouldBounceFirstRowOnMount: boolean = false;
|
||||
|
||||
static propTypes = {
|
||||
...FlatList.propTypes,
|
||||
|
||||
/**
|
||||
* To alert the user that swiping is possible, the first row can bounce
|
||||
* on component mount.
|
||||
*/
|
||||
bounceFirstRowOnMount: PropTypes.bool.isRequired,
|
||||
|
||||
// Maximum distance to open to after a swipe
|
||||
maxSwipeDistance: PropTypes.oneOfType([PropTypes.number, PropTypes.func])
|
||||
.isRequired,
|
||||
|
||||
// Callback method to render the view that will be unveiled on swipe
|
||||
renderQuickActions: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
static defaultProps = {
|
||||
...FlatList.defaultProps,
|
||||
bounceFirstRowOnMount: true,
|
||||
|
||||
@@ -10,11 +10,17 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
const DeprecatedViewPropTypes = require('DeprecatedViewPropTypes');
|
||||
const React = require('React');
|
||||
const StyleSheet = require('StyleSheet');
|
||||
const View = require('View');
|
||||
|
||||
import type {ViewStyleProp} from 'StyleSheet';
|
||||
|
||||
type Props = $ReadOnly<{|
|
||||
style?: ?ViewStyleProp,
|
||||
children: React.Node,
|
||||
|}>;
|
||||
|
||||
/**
|
||||
* A thin wrapper around standard quick action buttons that can, if the user
|
||||
* chooses, be used with SwipeableListView. Sample usage is as follows, in the
|
||||
@@ -25,13 +31,8 @@ const View = require('View');
|
||||
* <SwipeableQuickActionButton {..props} />
|
||||
* </SwipeableQuickActions>
|
||||
*/
|
||||
class SwipeableQuickActions extends React.Component<{style?: $FlowFixMe}> {
|
||||
static propTypes = {
|
||||
style: DeprecatedViewPropTypes.style,
|
||||
};
|
||||
|
||||
class SwipeableQuickActions extends React.Component<Props> {
|
||||
render(): React.Node {
|
||||
// $FlowFixMe found when converting React.createClass to ES6
|
||||
const children = this.props.children;
|
||||
let buttons = [];
|
||||
|
||||
@@ -40,8 +41,7 @@ class SwipeableQuickActions extends React.Component<{style?: $FlowFixMe}> {
|
||||
for (let i = 0; i < children.length; i++) {
|
||||
buttons.push(children[i]);
|
||||
|
||||
// $FlowFixMe found when converting React.createClass to ES6
|
||||
if (i < this.props.children.length - 1) {
|
||||
if (i < children.length - 1) {
|
||||
// Not last button
|
||||
buttons.push(<View key={i} style={styles.divider} />);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user