From d18a87993e4166bac332aa2d6f53c838205a7189 Mon Sep 17 00:00:00 2001 From: empyrical Date: Thu, 27 Sep 2018 20:25:15 -0600 Subject: [PATCH] SwipeableFlatList, SwipeableQuickActions: Remove PropTypes --- .../SwipeableRow/SwipeableFlatList.js | 36 +++++++------------ .../SwipeableRow/SwipeableQuickActions.js | 13 +++---- 2 files changed, 19 insertions(+), 30 deletions(-) diff --git a/Libraries/Experimental/SwipeableRow/SwipeableFlatList.js b/Libraries/Experimental/SwipeableRow/SwipeableFlatList.js index c2790f848a5979..cf54d9d502f7f8 100644 --- a/Libraries/Experimental/SwipeableRow/SwipeableFlatList.js +++ b/Libraries/Experimental/SwipeableRow/SwipeableFlatList.js @@ -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 = SwipableListProps & FlatListProps; -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 extends React.Component, State> { - props: Props; - state: State; - _flatListRef: ?FlatList = 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, diff --git a/Libraries/Experimental/SwipeableRow/SwipeableQuickActions.js b/Libraries/Experimental/SwipeableRow/SwipeableQuickActions.js index 4d2a43825f3b36..506a2ecc9993ba 100644 --- a/Libraries/Experimental/SwipeableRow/SwipeableQuickActions.js +++ b/Libraries/Experimental/SwipeableRow/SwipeableQuickActions.js @@ -10,11 +10,16 @@ '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, +|}>; + /** * 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,11 +30,7 @@ const View = require('View'); * * */ -class SwipeableQuickActions extends React.Component<{style?: $FlowFixMe}> { - static propTypes = { - style: DeprecatedViewPropTypes.style, - }; - +class SwipeableQuickActions extends React.Component { render(): React.Node { // $FlowFixMe found when converting React.createClass to ES6 const children = this.props.children;