File tree Expand file tree Collapse file tree
client/modules/IDE/components/Editor Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -94,6 +94,14 @@ export default function useCodeMirror({
9494 } ) ;
9595 }
9696
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+
97105 // When settings change, we pass those changes into CodeMirror.
98106 // TODO: There should be a useEffect hook for when the theme changes.
99107 useEffect ( ( ) => {
@@ -201,6 +209,7 @@ export default function useCodeMirror({
201209
202210 return {
203211 setupCodeMirrorOnContainerMounted,
212+ teardownCodeMirror,
204213 getContent,
205214 tidyCode
206215 // showFind,
Original file line number Diff line number Diff line change @@ -84,6 +84,7 @@ function Editor({
8484 // a reference to the actual CM instance.
8585 const {
8686 setupCodeMirrorOnContainerMounted,
87+ teardownCodeMirror,
8788 // cmInstance,
8889 getContent,
8990 tidyCode
@@ -130,6 +131,7 @@ function Editor({
130131
131132 return ( ) => {
132133 provideController ( null ) ;
134+ teardownCodeMirror ( ) ;
133135 } ;
134136 } , [ ] ) ;
135137
You can’t perform that action at this time.
0 commit comments