Skip to content

Commit 00836db

Browse files
committed
Fix formatting
1 parent dd02b69 commit 00836db

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

client/src/components/DynamicJsonForm.tsx

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -55,23 +55,26 @@ const DynamicJsonForm = ({
5555
const timeoutRef = useRef<ReturnType<typeof setTimeout>>();
5656

5757
// 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);
7263
}
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+
);
7578

7679
// Update rawJsonValue when value prop changes
7780
useEffect(() => {
@@ -353,7 +356,7 @@ const DynamicJsonForm = ({
353356
onChange={(newValue) => {
354357
// Always update local state
355358
setRawJsonValue(newValue);
356-
359+
357360
// Use the debounced function to attempt parsing and updating parent
358361
debouncedUpdateParent(newValue);
359362
}}

0 commit comments

Comments
 (0)