Create client componet and server component in same file
Answered
Dwarf Crocodile posted this in #help-forum
Dwarf CrocodileOP
I have some specific circumstances where i need to create a client component and server component in the same file. I can do it with multiple but i'm wondering, if for cleanliness i can do something like this.
but i just get
const a = () => {
return <div>Client</div>
}
const b = async() => {
"use server";
return <div>Server</div>
}but i just get
It is not allowed to define inline "use server" annotated Server Actions in Client ComponentsAnswered by Rafael Almeida
"use server" is a directive exclusive for server actions, it is not used for server components. so no you can't have them on the same file at the moment2 Replies
"use server" is a directive exclusive for server actions, it is not used for server components. so no you can't have them on the same file at the momentAnswer
Dwarf CrocodileOP
Ok thank you