copy: rename site branding to Krishna
This commit is contained in:
29
components/posts/button-client.tsx
Normal file
29
components/posts/button-client.tsx
Normal file
@@ -0,0 +1,29 @@
|
||||
'use client'
|
||||
|
||||
import { useEffect, useRef } from 'react'
|
||||
|
||||
export function ClientButton({
|
||||
children,
|
||||
onClick,
|
||||
...props
|
||||
}: {
|
||||
children?: React.ReactNode
|
||||
onClick?: ((event: React.MouseEvent<HTMLButtonElement>) => void) | string
|
||||
} & React.ButtonHTMLAttributes<HTMLButtonElement>) {
|
||||
const btnRef = useRef<HTMLButtonElement>(null)
|
||||
|
||||
useEffect(() => {
|
||||
if (!btnRef.current) return
|
||||
if (typeof onClick === 'string') {
|
||||
btnRef.current.onclick = onClick as unknown as (e: Event) => void
|
||||
} else if (typeof onClick === 'function') {
|
||||
btnRef.current.onclick = (e: Event) => onClick(e as unknown as React.MouseEvent<HTMLButtonElement>)
|
||||
}
|
||||
}, [onClick])
|
||||
|
||||
return (
|
||||
<button ref={btnRef} {...props}>
|
||||
{children}
|
||||
</button>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user