From 575b485c414c452c6311cce22555cf81236575cb Mon Sep 17 00:00:00 2001 From: Krishna Ayyalasomayajula Date: Tue, 2 Jun 2026 01:07:00 -0500 Subject: [PATCH] ui: update ClientButton to support function onClick alongside legacy string onClick --- components/blog/button-client.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/components/blog/button-client.tsx b/components/blog/button-client.tsx index 22c3c09..c709260 100644 --- a/components/blog/button-client.tsx +++ b/components/blog/button-client.tsx @@ -2,12 +2,22 @@ import { useEffect, useRef } from 'react' -export function ClientButton({ children, onClick, ...props }: { children?: React.ReactNode; onClick?: string } & React.ButtonHTMLAttributes) { +export function ClientButton({ + children, + onClick, + ...props +}: { + children?: React.ReactNode + onClick?: ((event: React.MouseEvent) => void) | string +} & React.ButtonHTMLAttributes) { const btnRef = useRef(null) useEffect(() => { - if (typeof onClick === 'string' && btnRef.current) { + if (!btnRef.current) return + if (typeof onClick === 'string') { btnRef.current.onclick = onClick as any + } else if (typeof onClick === 'function') { + btnRef.current.onclick = (e: Event) => onClick(e as React.MouseEvent) } }, [onClick])