refactor: remove FormDebug component and move DevT import to formDevTool

This commit is contained in:
Marco Pedone 2025-08-07 18:48:56 +02:00
parent 9ed9a4c39e
commit 1c420e2077
3 changed files with 8 additions and 23 deletions

View file

@ -14,7 +14,7 @@ FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
ENV NODE_ENV=production
ARG BASE_URL
ENV NEXT_PUBLIC_BASE_URL=$BASE_URL
ARG INTERNAL_BASE_URL

View file

@ -12,8 +12,6 @@ import {
import { cn } from "src/lib/utils";
import { Label } from "src/components/ui/label";
import dynamic from "next/dynamic";
import { env } from "~/env.mjs";
const Form = FormProvider;
@ -173,25 +171,6 @@ const FormMessage = React.forwardRef<
});
FormMessage.displayName = "FormMessage";
const FormDebug = React.forwardRef<
React.ElementType,
React.HTMLAttributes<HTMLDivElement>
>(() => {
if (env.NODE_ENV !== "development") {
return null;
}
const { control, formState } = useFormContext();
const DevT: React.ElementType = dynamic(
() => import("@hookform/devtools").then((module) => module.DevTool),
{ ssr: false },
);
if (Object.keys(formState.errors).length > 0) {
console.error("errors", formState.errors);
}
return <DevT control={control} />;
});
FormDebug.displayName = "FormDebug";
export {
useFormField,
Form,
@ -201,5 +180,4 @@ export {
FormDescription,
FormMessage,
FormField,
FormDebug,
};

View file

@ -0,0 +1,7 @@
import dynamic from "next/dynamic";
import type React from "react";
export const DevT: React.ElementType = dynamic(
() => import("@hookform/devtools").then((mod) => mod.DevTool),
{ ssr: false },
);