Skip to content

Commit

Permalink
SwipeableFlatList, SwipeableQuickActions: Remove PropTypes (#21384)
Browse files Browse the repository at this point in the history
Summary:
Part of: #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: #21384

Differential Revision: D10099694

Pulled By: TheSavior

fbshipit-source-id: 424b900942c9a7889b664f351f79abee55923430
  • Loading branch information
empyrical authored and facebook-github-bot committed Sep 28, 2018
1 parent 16f06bc commit 9104b04
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 33 deletions.
36 changes: 12 additions & 24 deletions Libraries/Experimental/SwipeableRow/SwipeableFlatList.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down
18 changes: 9 additions & 9 deletions Libraries/Experimental/SwipeableRow/SwipeableQuickActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 = [];

Expand All @@ -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} />);
}
Expand Down

0 comments on commit 9104b04

Please sign in to comment.