Skip to content

UI Library for Design Engineers. Animated components and effects you can copy and paste into your apps. Free. Open Source.

fix: fixed the dock component mouseX error (#352)

Arghya Das6bb776ed3eb2
diff --git a/registry/default/magicui/dock.tsx b/registry/default/magicui/dock.tsx
index 00f4f136..2655d997 100644
--- a/registry/default/magicui/dock.tsx
+++ b/registry/default/magicui/dock.tsx
@@ -18,7 +18,7 @@ const DEFAULT_MAGNIFICATION = 60;
const DEFAULT_DISTANCE = 140;
const dockVariants = cva(
- "mx-auto w-max mt-8 h-[58px] p-2 flex gap-2 rounded-2xl border supports-backdrop-blur:bg-white/10 supports-backdrop-blur:dark:bg-black/10 backdrop-blur-md",
+ "supports-backdrop-blur:bg-white/10 supports-backdrop-blur:dark:bg-black/10 mx-auto mt-8 flex h-[58px] w-max gap-2 rounded-2xl border p-2 backdrop-blur-md",
);
const Dock = React.forwardRef<HTMLDivElement, DockProps>(
@@ -36,12 +36,16 @@ const Dock = React.forwardRef<HTMLDivElement, DockProps>(
const mouseX = useMotionValue(Infinity);
const renderChildren = () => {
- return React.Children.map(children, (child: any) => {
- return React.cloneElement(child, {
- mouseX: mouseX,
- magnification: magnification,
- distance: distance,
- });
+ return React.Children.map(children, (child) => {
+ if (React.isValidElement(child) && child.type === DockIcon) {
+ return React.cloneElement(child, {
+ ...child.props,
+ mouseX: mouseX,
+ magnification: magnification,
+ distance: distance,
+ });
+ }
+ return child;
});
};