diff --git a/components/Editor/index.tsx b/components/Editor/index.tsx index 94e5475..3a0de10 100644 --- a/components/Editor/index.tsx +++ b/components/Editor/index.tsx @@ -98,12 +98,17 @@ const Editor = ({ readOnly = false }: Props) => { // eslint-disable-next-line react-hooks/exhaustive-deps }, [settingsLoaded && router.isReady]) - const logDiagnostics = (diagnostics: string[]) => { - for (const diagnostic of diagnostics) { - const type = diagnostic.startsWith('error') ? LogType.Error : LogType.Warn - log(diagnostic, type) - } - } + const logDiagnostics = useCallback( + (diagnostics: string[]) => { + for (const diagnostic of diagnostics) { + const type = diagnostic.startsWith('error') + ? LogType.Error + : LogType.Warn + log(diagnostic, type) + } + }, + [log], + ) useEffect(() => { if (isCompiling === CompilationState.Compiling) { @@ -117,7 +122,7 @@ const Editor = ({ readOnly = false }: Props) => { } else if (isCompiling === CompilationState.Error) { logDiagnostics(diagnostics) } - }, [isCompiling, log, serializedOutput]) + }, [isCompiling, serializedOutput, diagnostics, log, logDiagnostics]) const handleCairoCodeChange = (value: string) => { setCairoCode(value)