Client Button and Server Button
Answered
American Crow posted this in #help-forum
American CrowOP
I am starting to work on a project and trying to understand it.
The author has two components of Buttons.
One is using the
Other than that the Client Button seems to have no additional purpose
Client-Button.tsx
Why would you do something like that ? I cant really think of use cases when to use one over the other?
The author has two components of Buttons.
One is using the
use client directive in the begging and is basically just a wrapper for the the other button.Other than that the Client Button seems to have no additional purpose
Client-Button.tsx
"use client"
import { cn } from "@/lib/utils"
import { Button, type ButtonProps } from "@/components/ui/button"
interface ClientButtonProps extends ButtonProps {}
export function ClientButton({ className, ...props }: ClientButtonProps) {
return <Button className={cn(className)} {...props}></Button>
}Why would you do something like that ? I cant really think of use cases when to use one over the other?
Answered by Ray
use the one with
'use client' when you need to use event handler eg, onClick3 Replies
Answer
use the one without
'use client' when you just want to render a button tagAmerican CrowOP
omg how could i not see that. yea thank you