Monaco perf improvement: Update the editor focus only when its prop value has changed
vivek1729 opened this issue · comments
To update editor's focus state, we check if the passed in prop is true and if the editor is not already focused:
nteract/packages/monaco-editor/src/MonacoEditor.tsx
Lines 382 to 385 in d2088d0
Imagine a scenario where the passed in prop is true but the editor was already focused. We can see that we'd still end up calling the core hastTextFocus
api which can lead to low level dom queries and potential layout thrashing.
This can be optimized by checking prevProps
, following a similar pattern:
nteract/packages/monaco-editor/src/MonacoEditor.tsx
Lines 317 to 321 in d2088d0