Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hot reload not working in next.js #658

Open
aliotadi opened this issue Dec 21, 2024 · 0 comments
Open

hot reload not working in next.js #658

aliotadi opened this issue Dec 21, 2024 · 0 comments

Comments

@aliotadi
Copy link

when i update my code and save it(in "pnpm dev" command in nextjs), the issue is that the editor don't get the custom language that i defined, and i should manually refresh the page 3 times(i guess it's the absolute correct number of refreshes that i'm making each time) to get my changes, here is my code:

`export const TclEditor = () => {
const handleEditorDidMount = useCallback((editor: any, monaco: Monaco) => {
monaco.languages.register({ id: "tcl" });
monaco.languages.setMonarchTokensProvider(
"tcl",
tclLanguageDefinition as any
);

monaco.languages.registerCompletionItemProvider("tcl", {
  provideCompletionItems: (model, position) => {
    const word = model.getWordUntilPosition(position);
    const range = {
      startLineNumber: position.lineNumber,
      endLineNumber: position.lineNumber,
      startColumn: word.startColumn,
      endColumn: word.endColumn,
    };
    return {
      suggestions: tclCompletionItems.map((item) => ({
        ...item,
        range,
      })),
    };
  },
});

monaco.editor.defineTheme("test-theme", {
  base: "vs-dark",
  inherit: true,
  rules: [
    { token: "command", foreground: "00ffff" },
    { token: "number", foreground: "ff9900" },
    { token: "string", foreground: "ff00ff" },
    { token: "white", foreground: "ffffff" },
  ],
  colors: {},
});

monaco.editor.setTheme("test-theme");
console.log("Editor mounted");

}, []);
return (
<Editor
height={"100%"}
width={"50%"}
defaultLanguage="tcl"
defaultValue=""
theme="test-theme"
onMount={handleEditorDidMount}
options={{
minimap: { enabled: false },
scrollBeyondLastLine: false,
fontSize: 14,
}}
/>
);
};`

and i'm using this dependencies:
"dependencies": { "@fortawesome/fontawesome-svg-core": "^6.6.0", "@fortawesome/free-regular-svg-icons": "^6.6.0", "@fortawesome/free-solid-svg-icons": "^6.6.0", "@fortawesome/react-fontawesome": "^0.2.2", "@monaco-editor/react": "^4.6.0", "@react-three/drei": "^9.115.0", "@react-three/fiber": "8.17.10", "@reduxjs/toolkit": "^2.3.0", "next": "14.2.7", "react": "18.3.1", "react-dom": "18.3.1", "react-redux": "^9.1.2", "three": "^0.169.0" }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant