From 7abd76e78376e37771af2dedcdec9a96d89a07df Mon Sep 17 00:00:00 2001 From: Robert Daly Date: Sat, 19 Nov 2022 17:29:49 -0500 Subject: [PATCH] updating comment, added required to props --- .../CarouselActions/index.js | 19 ++++++------------- .../CarouselActions/index.native.js | 16 ++++------------ src/components/AttachmentModal.js | 4 +--- 3 files changed, 11 insertions(+), 28 deletions(-) diff --git a/src/components/AttachmentCarousel/CarouselActions/index.js b/src/components/AttachmentCarousel/CarouselActions/index.js index 85f24c2963c..5107543127b 100644 --- a/src/components/AttachmentCarousel/CarouselActions/index.js +++ b/src/components/AttachmentCarousel/CarouselActions/index.js @@ -3,14 +3,14 @@ import PropTypes from 'prop-types'; import {Pressable} from 'react-native'; const propTypes = { - /** handles onPress events with a callback */ - onPress: PropTypes.func, + /** Handles onPress events with a callback */ + onPress: PropTypes.func.isRequired, - /** can handle the cycling of attachments */ - onCycleThroughAttachments: PropTypes.func, + /** Callback to cycle through attachments */ + onCycleThroughAttachments: PropTypes.func.isRequired, - /** can be set to provide styles */ - styles: PropTypes.arrayOf(PropTypes.shape({})), + /** Styles to be assigned to Carousel */ + styles: PropTypes.arrayOf(PropTypes.object).isRequired, /** Children to render. */ children: PropTypes.oneOfType([ @@ -19,12 +19,6 @@ const propTypes = { ]).isRequired, }; -const defaultProps = { - styles: [], - onPress: () => {}, - onCycleThroughAttachments: () => {}, -}; - class Carousel extends React.Component { constructor(props) { super(props); @@ -64,6 +58,5 @@ class Carousel extends React.Component { } Carousel.propTypes = propTypes; -Carousel.defaultProps = defaultProps; export default Carousel; diff --git a/src/components/AttachmentCarousel/CarouselActions/index.native.js b/src/components/AttachmentCarousel/CarouselActions/index.native.js index e7484cd92b5..73ece096dc2 100644 --- a/src/components/AttachmentCarousel/CarouselActions/index.native.js +++ b/src/components/AttachmentCarousel/CarouselActions/index.native.js @@ -8,21 +8,14 @@ const propTypes = { children: PropTypes.element.isRequired, /** Callback to fire when swiping left or right */ - onCycleThroughAttachments: PropTypes.func, + onCycleThroughAttachments: PropTypes.func.isRequired, /** Callback to handle a press event because PanResponder will intercept all gestures */ - onPress: PropTypes.func, + onPress: PropTypes.func.isRequired, /** These help to prevent a swipe animation when at either end */ - canSwipeLeft: PropTypes.bool, - canSwipeRight: PropTypes.bool, -}; - -const defaultProps = { - onCycleThroughAttachments: () => {}, - onPress: () => {}, - canSwipeLeft: false, - canSwipeRight: false, + canSwipeLeft: PropTypes.bool.isRequired, + canSwipeRight: PropTypes.bool.isRequired, }; class Carousel extends Component { @@ -80,6 +73,5 @@ class Carousel extends Component { } Carousel.propTypes = propTypes; -Carousel.defaultProps = defaultProps; export default Carousel; diff --git a/src/components/AttachmentModal.js b/src/components/AttachmentModal.js index 36e70e07573..66b21c7e5d1 100755 --- a/src/components/AttachmentModal.js +++ b/src/components/AttachmentModal.js @@ -31,7 +31,7 @@ import HeaderGap from './HeaderGap'; */ const propTypes = { - /** Optional source URL for the image shown. If not passed in via props must be specified when modal is opened. */ + /** Optional source URL for the image shown also initializes Carousel's data. If not passed in via props must be specified when modal is opened. */ sourceURL: PropTypes.string, /** Optional callback to fire when we want to preview an image and approve it for use. */ @@ -78,7 +78,6 @@ class AttachmentModal extends PureComponent { isModalOpen: false, isConfirmModalOpen: false, reportId: null, - showArrows: false, file: {name: lodashGet(props, 'originalFileName', '')}, isAttachmentInvalid: false, attachmentInvalidReasonTitle: null, @@ -279,7 +278,6 @@ class AttachmentModal extends PureComponent { {this.state.reportId ? (