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: a11y fixes.
|
||||
// TODO: is the key necessary? Try switching themes without it.
|
||||
return (
|
||||
<Suspense fallback={<Loader timeout={600} />}>
|
||||
<span className='notranslate'>
|
||||
@ -335,7 +336,7 @@ class Editor extends Component {
|
||||
<MonacoEditor
|
||||
editorDidMount={this.editorDidMount}
|
||||
editorWillMount={this.editorWillMount}
|
||||
key={`${editorTheme}-${this.currentFileKey}`}
|
||||
key={`${editorTheme}`}
|
||||
onChange={this.onChange}
|
||||
options={this.options}
|
||||
theme={editorTheme}
|
||||
|
Reference in New Issue
Block a user