diff --git a/src/components/SwipeableView/index.js b/src/components/SwipeableView/index.js
deleted file mode 100644
index 96640b107608..000000000000
--- a/src/components/SwipeableView/index.js
+++ /dev/null
@@ -1,3 +0,0 @@
-export default ({children}) => children;
-
-// Swipeable View is available just on Android/iOS for now.
diff --git a/src/components/SwipeableView/index.native.js b/src/components/SwipeableView/index.native.tsx
similarity index 65%
rename from src/components/SwipeableView/index.native.js
rename to src/components/SwipeableView/index.native.tsx
index 2f1148721af1..ac500f025016 100644
--- a/src/components/SwipeableView/index.native.js
+++ b/src/components/SwipeableView/index.native.tsx
@@ -1,41 +1,34 @@
import React, {useRef} from 'react';
import {PanResponder, View} from 'react-native';
-import PropTypes from 'prop-types';
import CONST from '../../CONST';
+import SwipeableViewProps from './types';
-const propTypes = {
- children: PropTypes.element.isRequired,
-
- /** Callback to fire when the user swipes down on the child content */
- onSwipeDown: PropTypes.func.isRequired,
-};
-
-function SwipeableView(props) {
+function SwipeableView({children, onSwipeDown}: SwipeableViewProps) {
const minimumPixelDistance = CONST.COMPOSER_MAX_HEIGHT;
const oldYRef = useRef(0);
const panResponder = useRef(
PanResponder.create({
- // The PanResponder gets focus only when the y-axis movement is over minimumPixelDistance
- // & swipe direction is downwards
+ // The PanResponder gets focus only when the y-axis movement is over minimumPixelDistance & swipe direction is downwards
+ // eslint-disable-next-line @typescript-eslint/naming-convention
onMoveShouldSetPanResponderCapture: (_event, gestureState) => {
if (gestureState.dy - oldYRef.current > 0 && gestureState.dy > minimumPixelDistance) {
return true;
}
oldYRef.current = gestureState.dy;
+ return false;
},
// Calls the callback when the swipe down is released; after the completion of the gesture
- onPanResponderRelease: props.onSwipeDown,
+ onPanResponderRelease: onSwipeDown,
}),
).current;
return (
// eslint-disable-next-line react/jsx-props-no-spreading
- {props.children}
+ {children}
);
}
-SwipeableView.propTypes = propTypes;
SwipeableView.displayName = 'SwipeableView';
export default SwipeableView;
diff --git a/src/components/SwipeableView/index.tsx b/src/components/SwipeableView/index.tsx
new file mode 100644
index 000000000000..335c3e7dcf03
--- /dev/null
+++ b/src/components/SwipeableView/index.tsx
@@ -0,0 +1,4 @@
+import SwipeableViewProps from './types';
+
+// Swipeable View is available just on Android/iOS for now.
+export default ({children}: SwipeableViewProps) => children;
diff --git a/src/components/SwipeableView/types.ts b/src/components/SwipeableView/types.ts
new file mode 100644
index 000000000000..560df7ef5a45
--- /dev/null
+++ b/src/components/SwipeableView/types.ts
@@ -0,0 +1,11 @@
+import {ReactNode} from 'react';
+
+type SwipeableViewProps = {
+ /** The content to be rendered within the SwipeableView */
+ children: ReactNode;
+
+ /** Callback to fire when the user swipes down on the child content */
+ onSwipeDown: () => void;
+};
+
+export default SwipeableViewProps;