@@ -55,23 +55,26 @@ const DynamicJsonForm = ({
55
55
const timeoutRef = useRef < ReturnType < typeof setTimeout > > ( ) ;
56
56
57
57
// Create a debounced function to update parent state
58
- const debouncedUpdateParent = useCallback ( ( jsonString : string ) => {
59
- // Clear any existing timeout
60
- if ( timeoutRef . current ) {
61
- clearTimeout ( timeoutRef . current ) ;
62
- }
63
-
64
- // Set a new timeout
65
- timeoutRef . current = setTimeout ( ( ) => {
66
- try {
67
- const parsed = JSON . parse ( jsonString ) ;
68
- onChange ( parsed ) ;
69
- setJsonError ( undefined ) ;
70
- } catch {
71
- // Don't set error during normal typing
58
+ const debouncedUpdateParent = useCallback (
59
+ ( jsonString : string ) => {
60
+ // Clear any existing timeout
61
+ if ( timeoutRef . current ) {
62
+ clearTimeout ( timeoutRef . current ) ;
72
63
}
73
- } , 300 ) ;
74
- } , [ onChange , setJsonError ] ) ;
64
+
65
+ // Set a new timeout
66
+ timeoutRef . current = setTimeout ( ( ) => {
67
+ try {
68
+ const parsed = JSON . parse ( jsonString ) ;
69
+ onChange ( parsed ) ;
70
+ setJsonError ( undefined ) ;
71
+ } catch {
72
+ // Don't set error during normal typing
73
+ }
74
+ } , 300 ) ;
75
+ } ,
76
+ [ onChange , setJsonError ] ,
77
+ ) ;
75
78
76
79
// Update rawJsonValue when value prop changes
77
80
useEffect ( ( ) => {
@@ -353,7 +356,7 @@ const DynamicJsonForm = ({
353
356
onChange = { ( newValue ) => {
354
357
// Always update local state
355
358
setRawJsonValue ( newValue ) ;
356
-
359
+
357
360
// Use the debounced function to attempt parsing and updating parent
358
361
debouncedUpdateParent ( newValue ) ;
359
362
} }
0 commit comments