So to break it down it down I have a form component that I want to move from a client component to a server component.
However every time I remove the "use client" at the top I am getting this error.
For more context this is my code
"use client" // This is the use client I want to remove
// Import necessary modules and components
import ChannelInput from '@/components/custom/form/FormInput/ChannelInput';
import ProjectNameInput from '@/components/custom/form/FormInput/ProjectNameInput';
import ChainInput from '@/components/custom/form/FormInput/ChainInput';
import TelegramLinkInput from '@/components/custom/form/FormInput/TelegramLinkInput';
import WebsiteLinkInput from '@/components/custom/form/FormInput/WebsiteLinkInput';
import ImageLinkInput from '@/components/custom/form/FormInput/ImageLinkInput';
import ContractAddressInput from '@/components/custom/form/FormInput/ContractAddressInput';
import PinnedPostInput from '@/components/custom/form/FormInput/PinnedPostInput';
import {
Form,
} from "@/components/ui/form";
import DescriptionInput from "./FormInput/DescriptionInput";
import { SubmitButton, onSubmit } from "./FormInput/FormSubmit";
import { useMainForm } from "@/hooks/useMainForm";
export function MainForm() {
// Use the useForm hook with the FormSchema for form validation
const form = useMainForm();
// Render the form using the Form and related components
return (
<Form {...form}>
<form
onSubmit={form.handleSubmit(onSubmit)}
className="grid grid-cols-2 gap-3 space-y-1"
>
{/* Channel Input */}
<div className="col-span-2">
<ChannelInput />
</div>
{/* Project Name Input */}
<div>
<ProjectNameInput />
</div>
{/* Chain Input */}
<div>
<ChainInput />
</div>
{/* Description Input */}
<div className="col-span-2">
<DescriptionInput />
</div>
{/* Telegram Link Input */}
<div>
<TelegramLinkInput />
</div>
{/* Website Link Input */}
<div>
<WebsiteLinkInput />
</div>
{/* Contract Address Link Input */}
<div className="col-span-2">
<ContractAddressInput />
</div>
{/* Image Link Input */}
<div className="col-span-2">
<ImageLinkInput />
</div>
{/* Pinned Post Input */}
<div className="col-span-2">
<PinnedPostInput />
</div>
<div className="col-span-2 flex justify-center">
{/* Submit button */}
<SubmitButton />
</div>
</form>
</Form>
);
}
and for context this is one of the inputs, they all have the similar style, I have tried to add "use client" to all of the inputs but it still didn't work. Would really like some more help on this.
import { FormField, FormItem, FormLabel, FormControl, FormDescription, FormMessage } from "@/components/ui/form";
import { Textarea } from "@/components/ui/textarea"
import { useFormContext } from "react-hook-form";
export default function DescriptionInput() {
const { control } = useFormContext();
return (
<FormField
control={control}
name="description"
render={({ field }) => (
<FormItem>
<FormLabel>Description</FormLabel>
<FormControl>
<Textarea
placeholder="Tell us a little bit about your project."
className="resize-none"
{...field}
/>
</FormControl>
<FormDescription>
Type a message you want displayed on the group.
</FormDescription>
<FormMessage />
</FormItem>
)}
/>
);
}