File tree Expand file tree Collapse file tree 2 files changed +29
-17
lines changed Expand file tree Collapse file tree 2 files changed +29
-17
lines changed Original file line number Diff line number Diff line change @@ -239,21 +239,13 @@ export function DynamicForm() {
239
239
< Controller
240
240
name = { param . name }
241
241
control = { methods . control }
242
- render = { ( { field } ) => {
243
- const { debounced } = useDebouncedFunction (
244
- ( e : React . ChangeEvent < HTMLInputElement > ) => field . onChange ( e ) ,
245
- 1000
246
- ) ;
247
-
248
- return (
249
- < Input
250
- onChange = { debounced }
251
- className = "w-[300px]"
252
- type = { mapParamTypeToInputType ( param . type ) }
253
- defaultValue = { param . default_value }
254
- />
255
- ) ;
256
- } }
242
+ render = { ( { field } ) => (
243
+ < DebouncedInput
244
+ field = { field }
245
+ type = { mapParamTypeToInputType ( param . type ) }
246
+ defaultValue = { param . default_value }
247
+ />
248
+ ) }
257
249
/>
258
250
{ renderDiagnostics ( param . diagnostics ) }
259
251
</ div >
@@ -273,6 +265,26 @@ export function DynamicForm() {
273
265
) ;
274
266
} ;
275
267
268
+ const DebouncedInput = ( { field, type, defaultValue } : {
269
+ field : { onChange : ( e : React . ChangeEvent < HTMLInputElement > ) => void } ,
270
+ type : string ,
271
+ defaultValue ?: string
272
+ } ) => {
273
+ const { debounced } = useDebouncedFunction (
274
+ ( e : React . ChangeEvent < HTMLInputElement > ) => field . onChange ( e ) ,
275
+ 2000
276
+ ) ;
277
+
278
+ return (
279
+ < Input
280
+ onChange = { debounced }
281
+ className = "w-[300px]"
282
+ type = { type }
283
+ defaultValue = { defaultValue }
284
+ />
285
+ ) ;
286
+ } ;
287
+
276
288
if ( isLoading && directories . length === 0 ) {
277
289
return < div > Loading directories...</ div > ;
278
290
}
Original file line number Diff line number Diff line change @@ -25,7 +25,8 @@ export function useWebSocket<T>(url: string, testdata: string) {
25
25
console . log ( "Received message:" , data ) ;
26
26
setMessage ( data ) ;
27
27
} catch ( err ) {
28
- console . error ( "Invalid JSON from server:" , event . data ) ;
28
+ console . error ( "Invalid JSON from server: " , event . data ) ;
29
+ console . error ( "Error: " , err ) ;
29
30
}
30
31
} ;
31
32
@@ -51,7 +52,6 @@ export function useWebSocket<T>(url: string, testdata: string) {
51
52
setMessage ( null ) ;
52
53
setConnectionStatus ( 'connecting' ) ;
53
54
54
- // Create new connection after a small delay to ensure cleanup completes
55
55
const createConnection = ( ) => {
56
56
urlRef . current = url ;
57
57
connectWebSocket ( ) ;
You can’t perform that action at this time.
0 commit comments