From bedc983d2ad9084592743e9f77a7eab995fbd0f4 Mon Sep 17 00:00:00 2001 From: Jordan Eldredge Date: Sat, 17 Sep 2022 16:21:17 -0700 Subject: [PATCH] Small cleanup of WinampButton Missing hook dependency, and use default destructuring instead of defaultProps --- packages/webamp/js/components/WinampButton.tsx | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/packages/webamp/js/components/WinampButton.tsx b/packages/webamp/js/components/WinampButton.tsx index a3e53c10..62fa1030 100644 --- a/packages/webamp/js/components/WinampButton.tsx +++ b/packages/webamp/js/components/WinampButton.tsx @@ -31,13 +31,12 @@ type Props = DetailedHTMLPropsAndMore; * > and the time it is depressed; for a finger in a multitouch environment, while * > the finger is touching the display surface). */ -export default function WinampButton(props: Props): JSX.Element { +export default function WinampButton({ + requireClicksOriginateLocally = true, + onPointerDown: originalOnPointerDown, + ...htmlProps +}: Props): JSX.Element { const [active, setActive] = useState(false); - const { - requireClicksOriginateLocally, - onPointerDown: originalOnPointerDown, - ...htmlProps - } = props; const onPointerDown = useCallback( (e) => { @@ -66,7 +65,7 @@ export default function WinampButton(props: Props): JSX.Element { } document.addEventListener("pointerup", onRelease); }, - [originalOnPointerDown] + [originalOnPointerDown, requireClicksOriginateLocally] ); // We watch for events onPointerEnter only when requireClicksOriginateLocally === false @@ -97,7 +96,3 @@ export default function WinampButton(props: Props): JSX.Element { /> ); } - -WinampButton.defaultProps = { - requireClicksOriginateLocally: true, -};