From 9104b0426103748c528768c9dd4237b1448c54fa Mon Sep 17 00:00:00 2001 From: empyrical Date: Fri, 28 Sep 2018 00:16:59 -0700 Subject: [PATCH] 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 --- .../SwipeableRow/SwipeableFlatList.js | 36 +++++++------------ .../SwipeableRow/SwipeableQuickActions.js | 18 +++++----- 2 files changed, 21 insertions(+), 33 deletions(-) diff --git a/Libraries/Experimental/SwipeableRow/SwipeableFlatList.js b/Libraries/Experimental/SwipeableRow/SwipeableFlatList.js index c2790f848..cf54d9d50 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 4d2a43825..c97f77648 100644 --- a/Libraries/Experimental/SwipeableRow/SwipeableQuickActions.js +++ b/Libraries/Experimental/SwipeableRow/SwipeableQuickActions.js @@ -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'); * * */ -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; 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(); }