fix: prevent unnecessary re-renders
The editor should handle its own rendering. By including a key that changes as the users changes tabs forces the editor to re-render. This gets triggered as the user types, resetting the cursor to the start of the editor. Now the key only changes if the theme changes.
This commit is contained in:
committed by
Mrugesh Mohapatra
parent
4de5c5fde3
commit
b0f18cacc7
@ -303,6 +303,7 @@ class Editor extends Component {
|
|||||||
|
|
||||||
// TODO: tabs should be dynamically created from the challengeFiles
|
// TODO: tabs should be dynamically created from the challengeFiles
|
||||||
// TODO: a11y fixes.
|
// TODO: a11y fixes.
|
||||||
|
// TODO: is the key necessary? Try switching themes without it.
|
||||||
return (
|
return (
|
||||||
<Suspense fallback={<Loader timeout={600} />}>
|
<Suspense fallback={<Loader timeout={600} />}>
|
||||||
<span className='notranslate'>
|
<span className='notranslate'>
|
||||||
@ -335,7 +336,7 @@ class Editor extends Component {
|
|||||||
<MonacoEditor
|
<MonacoEditor
|
||||||
editorDidMount={this.editorDidMount}
|
editorDidMount={this.editorDidMount}
|
||||||
editorWillMount={this.editorWillMount}
|
editorWillMount={this.editorWillMount}
|
||||||
key={`${editorTheme}-${this.currentFileKey}`}
|
key={`${editorTheme}`}
|
||||||
onChange={this.onChange}
|
onChange={this.onChange}
|
||||||
options={this.options}
|
options={this.options}
|
||||||
theme={editorTheme}
|
theme={editorTheme}
|
||||||
|
Reference in New Issue
Block a user