@@ -551,28 +551,28 @@ export class Controlled extends React.Component<IControlledCodeMirror, any> {
551551 }
552552
553553 /** @internal */
554- public componentWillReceiveProps ( nextProps ) {
554+ public componentDidUpdate ( prevProps ) {
555555
556556 if ( SERVER_RENDERED ) return ;
557557
558558 let preserved : IPreservedOptions = { cursor : null } ;
559559
560- if ( nextProps . value !== this . props . value ) {
560+ if ( this . props . value !== prevProps . value ) {
561561 this . hydrated = false ;
562562 }
563563
564564 if ( ! this . props . autoCursor && this . props . autoCursor !== undefined ) {
565565 preserved . cursor = this . editor . getDoc ( ) . getCursor ( ) ;
566566 }
567567
568- this . hydrate ( nextProps ) ;
568+ this . hydrate ( this . props ) ;
569569
570570 if ( ! this . appliedNext ) {
571- this . shared . applyNext ( this . props , nextProps , preserved ) ;
571+ this . shared . applyNext ( prevProps , this . props , preserved ) ;
572572 this . appliedNext = true ;
573573 }
574574
575- this . shared . applyUserDefined ( this . props , preserved ) ;
575+ this . shared . applyUserDefined ( prevProps , preserved ) ;
576576 this . appliedUserDefined = true ;
577577 }
578578
@@ -736,45 +736,44 @@ export class UnControlled extends React.Component<IUnControlledCodeMirror, any>
736736 }
737737
738738 /** @internal */
739- public componentWillReceiveProps ( nextProps ) {
740-
741- if ( this . detached && ( nextProps . detach === false ) ) {
739+ public componentDidUpdate ( prevProps ) {
740+ if ( this . detached && ( this . props . detach === false ) ) {
742741 this . detached = false ;
743- if ( this . props . editorDidAttach ) {
744- this . props . editorDidAttach ( this . editor ) ;
742+ if ( prevProps . editorDidAttach ) {
743+ prevProps . editorDidAttach ( this . editor ) ;
745744 }
746745 }
747746
748- if ( ! this . detached && ( nextProps . detach === true ) ) {
747+ if ( ! this . detached && ( this . props . detach === true ) ) {
749748 this . detached = true ;
750- if ( this . props . editorDidDetach ) {
751- this . props . editorDidDetach ( this . editor ) ;
749+ if ( prevProps . editorDidDetach ) {
750+ prevProps . editorDidDetach ( this . editor ) ;
752751 }
753752 }
754753
755754 if ( SERVER_RENDERED || this . detached ) return ;
756755
757756 let preserved : IPreservedOptions = { cursor : null } ;
758757
759- if ( nextProps . value !== this . props . value ) {
758+ if ( this . props . value !== prevProps . value ) {
760759 this . hydrated = false ;
761760 this . applied = false ;
762761 this . appliedUserDefined = false ;
763762 }
764763
765- if ( ! this . props . autoCursor && this . props . autoCursor !== undefined ) {
764+ if ( ! prevProps . autoCursor && prevProps . autoCursor !== undefined ) {
766765 preserved . cursor = this . editor . getDoc ( ) . getCursor ( ) ;
767766 }
768767
769- this . hydrate ( nextProps ) ;
768+ this . hydrate ( this . props ) ;
770769
771770 if ( ! this . applied ) {
772- this . shared . apply ( this . props ) ;
771+ this . shared . apply ( prevProps ) ;
773772 this . applied = true ;
774773 }
775774
776775 if ( ! this . appliedUserDefined ) {
777- this . shared . applyUserDefined ( this . props , preserved ) ;
776+ this . shared . applyUserDefined ( prevProps , preserved ) ;
778777 this . appliedUserDefined = true ;
779778 }
780779 }
@@ -795,7 +794,7 @@ export class UnControlled extends React.Component<IUnControlledCodeMirror, any>
795794 let update = true ;
796795
797796 if ( SERVER_RENDERED ) update = false ;
798- if ( this . detached ) update = false ;
797+ if ( this . detached && nextProps . detach ) update = false ;
799798
800799 return update ;
801800 }
0 commit comments