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

cannot call editor.setValue in editorDidMount #685

Open
1 task
genshen opened this issue Jan 2, 2023 · 3 comments
Open
1 task

cannot call editor.setValue in editorDidMount #685

genshen opened this issue Jan 2, 2023 · 3 comments

Comments

@genshen
Copy link

genshen commented Jan 2, 2023

Describe the bug
I run the latest example in react-monaco-editor (8dba5e3, [email protected]).
It can not set editor content in editorDidMount.

To Reproduce
([email protected], [email protected])
Clone react-monaco-editor repo and cd the example directory. change editorDidMount in class CodeEditor to:

 editorDidMount = (editor) => {
    // eslint-disable-next-line no-console
    console.log("editorDidMount", editor, editor.getValue(), editor.getModel());
    this.editor = editor;
+    editor.setValue("// new value");
  };

The editor ui does not change to "// new value".
But if we switch to ([email protected] and [email protected]), it works well (can show "// new value").

Expected behavior
It can show "// new value" under [email protected].

Screenshots/Logs

Environment (please complete the following information):

  • OS: MacOS 13.1 (22C65)

  • Browser: Firefox 108.0.1

  • Bundler: webpack

  • I will try to send a pull request to fix this issue.

@thoughtpalette
Copy link

Believe we're running into the same issue. Any progress?

@thoughtpalette
Copy link

Can also confirm [email protected] does not have this issue and works as expected. I would also like to point out addExtraLib doesn't work with editor.setValue in the latest version.

@genshen
Copy link
Author

genshen commented Mar 22, 2023

Believe we're running into the same issue. Any progress?

I switched to use https://github.com/suren-atoyan/monaco-react, it works well.

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

2 participants