Skip to content

armgit / vaul

Public Imported from GitHub
0

A drawer component for React.

Fix `useCallback` to not be conditionally rendered (#542)

Sean Templeton54b099cfeed7
diff --git a/src/index.tsx b/src/index.tsx
index 691e95b..3ed6755 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -804,14 +804,13 @@ export const Overlay = React.forwardRef<HTMLDivElement, React.ComponentPropsWith
const { overlayRef, snapPoints, onRelease, shouldFade, isOpen, modal, shouldAnimate } = useDrawerContext();
const composedRef = useComposedRefs(ref, overlayRef);
const hasSnapPoints = snapPoints && snapPoints.length > 0;
+ const onMouseUp = React.useCallback((event: React.PointerEvent<HTMLDivElement>) => onRelease(event), [onRelease]);
// Overlay is the component that is locking scroll, removing it will unlock the scroll without having to dig into Radix's Dialog library
if (!modal) {
return null;
}
- const onMouseUp = React.useCallback((event: React.PointerEvent<HTMLDivElement>) => onRelease(event), [onRelease]);
-
return (
<DialogPrimitive.Overlay
onMouseUp={onMouseUp}