File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed
client/modules/IDE/components/Editor Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -94,6 +94,14 @@ export default function useCodeMirror({
94
94
} ) ;
95
95
}
96
96
97
+ // When the component unmounts, we want to clean up the CodeMirror instance.
98
+ function teardownCodeMirror ( ) {
99
+ if ( cmView . current ) {
100
+ cmView . current . destroy ( ) ;
101
+ cmView . current = null ;
102
+ }
103
+ }
104
+
97
105
// When settings change, we pass those changes into CodeMirror.
98
106
// TODO: There should be a useEffect hook for when the theme changes.
99
107
useEffect ( ( ) => {
@@ -201,6 +209,7 @@ export default function useCodeMirror({
201
209
202
210
return {
203
211
setupCodeMirrorOnContainerMounted,
212
+ teardownCodeMirror,
204
213
getContent,
205
214
tidyCode
206
215
// showFind,
Original file line number Diff line number Diff line change @@ -84,6 +84,7 @@ function Editor({
84
84
// a reference to the actual CM instance.
85
85
const {
86
86
setupCodeMirrorOnContainerMounted,
87
+ teardownCodeMirror,
87
88
// cmInstance,
88
89
getContent,
89
90
tidyCode
@@ -130,6 +131,7 @@ function Editor({
130
131
131
132
return ( ) => {
132
133
provideController ( null ) ;
134
+ teardownCodeMirror ( ) ;
133
135
} ;
134
136
} , [ ] ) ;
135
137
You can’t perform that action at this time.
0 commit comments