fix(client): circular function calls leads to memory leak (#1049)
* fix(client): circular function call leads to memory leak * allow children validation
This commit is contained in:
parent
fc7897f380
commit
885c8bc732
1 changed files with 11 additions and 3 deletions
|
|
@ -28,6 +28,7 @@ interface DynamicJsonFormProps {
|
|||
|
||||
export interface DynamicJsonFormRef {
|
||||
validateJson: () => { isValid: boolean; error: string | null };
|
||||
hasJsonError: () => boolean;
|
||||
}
|
||||
|
||||
const isTypeSupported = (
|
||||
|
|
@ -129,6 +130,10 @@ const DynamicJsonForm = forwardRef<DynamicJsonFormRef, DynamicJsonFormProps>(
|
|||
// on every keystroke which would be inefficient and error-prone
|
||||
const timeoutRef = useRef<ReturnType<typeof setTimeout>>();
|
||||
|
||||
const hasJsonError = () => {
|
||||
return !!jsonError;
|
||||
};
|
||||
|
||||
// Debounce JSON parsing and parent updates to handle typing gracefully
|
||||
const debouncedUpdateParent = useCallback(
|
||||
(jsonString: string) => {
|
||||
|
|
@ -253,6 +258,7 @@ const DynamicJsonForm = forwardRef<DynamicJsonFormRef, DynamicJsonFormProps>(
|
|||
|
||||
useImperativeHandle(ref, () => ({
|
||||
validateJson,
|
||||
hasJsonError,
|
||||
}));
|
||||
|
||||
const renderFormFields = (
|
||||
|
|
|
|||
Loading…
Reference in a new issue