From c32b1ad211426676b292fb5532ded47c6b5c49db Mon Sep 17 00:00:00 2001 From: Nattapong Saengphrom Date: Mon, 26 Dec 2022 11:08:58 +0700 Subject: [PATCH] fix: remove default props from function component to support 18.3.0 --- src/ReactCompareImage.tsx | 56 ++++++++++++--------------------------- 1 file changed, 17 insertions(+), 39 deletions(-) diff --git a/src/ReactCompareImage.tsx b/src/ReactCompareImage.tsx index 899ff37..50f9dfd 100644 --- a/src/ReactCompareImage.tsx +++ b/src/ReactCompareImage.tsx @@ -21,45 +21,26 @@ interface IProps { vertical?: boolean; } -const defaultProps = { - aspectRatio: 'taller', - handle: null, - handleSize: 40, - hover: false, - leftImageAlt: '', - leftImageCss: {}, - leftImageLabel: null, - onSliderPositionChange: () => {}, - rightImageAlt: '', - rightImageCss: {}, - rightImageLabel: null, - skeleton: null, - sliderLineColor: '#ffffff', - sliderLineWidth: 2, - sliderPositionPercentage: 0.5, - vertical: false, -}; - -const ReactCompareImage: React.FC = props => { +const ReactCompareImage: React.FC = (props: IProps) => { const { - aspectRatio, - handle, - handleSize, - hover, + aspectRatio = 'taller', + handle = null, + handleSize = 40, + hover = false, leftImage, - leftImageAlt, - leftImageCss, - leftImageLabel, - onSliderPositionChange, + leftImageAlt = '', + leftImageCss = {}, + leftImageLabel = null, + onSliderPositionChange = () => {}, rightImage, - rightImageAlt, - rightImageCss, - rightImageLabel, - skeleton, - sliderLineColor, - sliderLineWidth, - sliderPositionPercentage, - vertical, + rightImageAlt = '', + rightImageCss = {}, + rightImageLabel = null, + skeleton = null, + sliderLineColor = '#ffffff', + sliderLineWidth = 2, + sliderPositionPercentage = 0.5, + vertical = false, } = props; const horizontal = !vertical; @@ -435,7 +416,4 @@ const ReactCompareImage: React.FC = props => { ); }; -// @ts-ignore -ReactCompareImage.defaultProps = defaultProps; - export default ReactCompareImage;