Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions modules/playground/components/playground-editor.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";

import { EDITOR_CONFIG } from "@/lib/constants/config";
import { useRef, useEffect, useState } from "react";
import { useRef, useEffect, useState, useCallback } from "react";
import Editor, { type Monaco } from "@monaco-editor/react";
import type { editor as MonacoEditor } from "monaco-editor";
import {
Expand Down Expand Up @@ -253,7 +253,7 @@ const PlaygroundEditor = ({
);
};

const updateEditorLanguage = () => {
const updateEditorLanguage = useCallback(() => {
if (!activeFile || !monacoRef.current || !editorRef.current) return;
const model = editorRef.current.getModel();
if (!model) return;
Expand All @@ -264,12 +264,11 @@ const PlaygroundEditor = ({
} catch (error) {
console.warn("Failed to set editor language:", error);
}
};
}, [activeFile]);

useEffect(() => {
updateEditorLanguage();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [activeFile]);
}, [updateEditorLanguage]);

// Bind Yjs to Monaco
useEffect(() => {
Expand Down