fix: use client-side ref to handle onclick string from transformerCopyButton

This commit is contained in:
2026-06-01 23:31:20 -05:00
parent 473774d0ca
commit a12b13f7d1
2 changed files with 24 additions and 5 deletions

View File

@@ -0,0 +1,19 @@
'use client'
import { useEffect, useRef } from 'react'
export function ClientButton({ children, onClick, ...props }: { children?: React.ReactNode; onClick?: string } & React.ButtonHTMLAttributes<HTMLButtonElement>) {
const btnRef = useRef<HTMLButtonElement>(null)
useEffect(() => {
if (typeof onClick === 'string' && btnRef.current) {
btnRef.current.onclick = onClick as any
}
}, [onClick])
return (
<button ref={btnRef} {...props}>
{children}
</button>
)
}