@@ -45,21 +45,7 @@ type FieldValues = Record<string, any>;
4545type Path < T extends FieldValues > = keyof T ;
4646type RegisterOptions < T extends FieldValues = FieldValues , TName extends Path < T > = Path < T > > = any ;
4747
48- // Get Controller dynamically
49- let ControllerComponent : any = null ;
50- try {
51- if ( typeof window !== 'undefined' ) {
52- // Client-side dynamic import
53- import ( 'react-hook-form' ) . then ( rhf => {
54- ControllerComponent = rhf . Controller ;
55- } ) ;
56- } else {
57- // Server-side - Controller won't work anyway, so skip
58- ControllerComponent = null ;
59- }
60- } catch {
61- // react-hook-form not available
62- }
48+ // Note: Controller is dynamically loaded at runtime in each component function
6349
6450// Base adapter props
6551interface BaseRHFProps < T extends FieldValues , TName extends Path < T > > {
@@ -83,7 +69,7 @@ export function RHFForgeInput<T extends FieldValues, TName extends Path<T>>({
8369 // Simple wrapper that uses runtime require to avoid build issues
8470 let Controller : any = null ;
8571 try {
86- Controller = ( global as any ) . reactHookFormController || ( typeof require !== 'undefined' ? require ( 'react-hook-form' ) ?. Controller : null ) ;
72+ Controller = ( global as any ) . reactHookFormController ;
8773 } catch {
8874 Controller = null ;
8975 }
@@ -127,7 +113,7 @@ export function RHFForgeSelect<T extends FieldValues, TName extends Path<T>>({
127113} : RHFForgeSelectProps < T , TName > ) {
128114 let Controller : any = null ;
129115 try {
130- Controller = ( global as any ) . reactHookFormController || ( typeof require !== 'undefined' ? require ( 'react-hook-form' ) ?. Controller : null ) ;
116+ Controller = ( global as any ) . reactHookFormController ;
131117 } catch {
132118 Controller = null ;
133119 }
@@ -170,7 +156,7 @@ export function RHFForgeCheckbox<T extends FieldValues, TName extends Path<T>>({
170156} : RHFForgeCheckboxProps < T , TName > ) {
171157 let Controller : any = null ;
172158 try {
173- Controller = ( global as any ) . reactHookFormController || ( typeof require !== 'undefined' ? require ( 'react-hook-form' ) ?. Controller : null ) ;
159+ Controller = ( global as any ) . reactHookFormController ;
174160 } catch {
175161 Controller = null ;
176162 }
@@ -212,7 +198,7 @@ export function RHFForgeRadioGroup<T extends FieldValues, TName extends Path<T>>
212198} : RHFForgeRadioGroupProps < T , TName > ) {
213199 let Controller : any = null ;
214200 try {
215- Controller = ( global as any ) . reactHookFormController || ( typeof require !== 'undefined' ? require ( 'react-hook-form' ) ?. Controller : null ) ;
201+ Controller = ( global as any ) . reactHookFormController ;
216202 } catch {
217203 Controller = null ;
218204 }
@@ -258,7 +244,7 @@ export function createRHFAdapter<
258244 } : BaseRHFProps < T , TName > & TProps ) {
259245 let Controller : any = null ;
260246 try {
261- Controller = ( global as any ) . reactHookFormController || ( typeof require !== 'undefined' ? require ( 'react-hook-form' ) ?. Controller : null ) ;
247+ Controller = ( global as any ) . reactHookFormController ;
262248 } catch {
263249 Controller = null ;
264250 }
0 commit comments