nteract / nteract

📘 The interactive computing suite for you! ✨

Home Page:https://nteract.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Monaco perf improvement: Call updateOptions API only for props that have changed

vivek1729 opened this issue · comments

We rely on the helpful updateOptions API on the editor instance to update a generic set of options. Since, this is tied to the componentDidUpdate lifecycle method, several calls to the underlying updateOptions API can lead to potentially unwanted dom manipulations.

We can consider adding some checks before calling this API so that we pass in only those props that have actually changed since the last update:

const monacoUpdateOptions: monaco.editor.IEditorOptions & monaco.editor.IGlobalEditorOptions = { readOnly: this.props.readOnly };
if (theme) {
monacoUpdateOptions.theme = theme;
}
this.editor.updateOptions(monacoUpdateOptions);