question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Expose a `editorWillMount` callback

See original GitHub issue

Hi, first of all thanks for this wonderful lib!

Is it possible to expose a prop for a callback to fire after the monaco.init() and before the call to monacoInstance.editor.create() ?

something like:

async function someFunc() {
  const monacoInstance = await monaco.init();

  // fire a callback that returns a promise here...
  if (props.editorWillMount) {
    await props.editorWillMount(monacoInstance);
  }

  const wrapper = document.getElementById('some-id');
  const editor = monacoInstance.editor.create(wrapper, options);

  if (props.editorDidMount) {
    props.editorDidMount(editor);
  }
}

Thing is, I need to do some async operations before the editor is being created.

Thanks!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
danielemeshcommented, Jan 18, 2021

Hi, Thanks for the update, I’ll post a feedback here as soon as I’ll upgrade to v4. I read the changelog, and seems like I’ll be using most of the new additions! Currently I have a wrapper around your Editor component which does all these new stuff 😀.

BTW your docs are also very well written, it’s obvious you care a lot for your consumers!

1reaction
suren-atoyancommented, Jan 17, 2021

Hello @danielemesh

The new version is here 🙂 And as I promised, there is something like editorWillMount, it’s called beforeMount. I would love to get feedback about the new version.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Passing callbacks down with React Hooks - Medium
A pattern to pass callbacks down through component's hierarchy by sharing a memoized API object through the React Context.
Read more >
Monaco Editor for React - Morioh
editorWillMount (monaco) an event emitted before the editor mounted (similar to componentWillMount of React). editorDidMount(editor, monaco) an event emitted ...
Read more >
How to effectively initialise client register callback in react ...
I am trining use factory class in react functional component. I need initialise base on components props and do it in first render...
Read more >
Feature - expose the raw doc object to Canvas's paint callback ...
I'd like to use svg-to-pdfkit to render an SVG into a PDF I'm building. It requires a handle to the PDFKit document, which...
Read more >
React 5-Minute Tips: React Callback Hooks - YouTube
This quick video will teach you how to improve React functional component performance with Callback Hooks. You can also download the code ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found