@@ -551,28 +551,28 @@ export class Controlled extends React.Component<IControlledCodeMirror, any> {
551
551
}
552
552
553
553
/** @internal */
554
- public componentWillReceiveProps ( nextProps ) {
554
+ public componentDidUpdate ( prevProps ) {
555
555
556
556
if ( SERVER_RENDERED ) return ;
557
557
558
558
let preserved : IPreservedOptions = { cursor : null } ;
559
559
560
- if ( nextProps . value !== this . props . value ) {
560
+ if ( this . props . value !== prevProps . value ) {
561
561
this . hydrated = false ;
562
562
}
563
563
564
564
if ( ! this . props . autoCursor && this . props . autoCursor !== undefined ) {
565
565
preserved . cursor = this . editor . getDoc ( ) . getCursor ( ) ;
566
566
}
567
567
568
- this . hydrate ( nextProps ) ;
568
+ this . hydrate ( this . props ) ;
569
569
570
570
if ( ! this . appliedNext ) {
571
- this . shared . applyNext ( this . props , nextProps , preserved ) ;
571
+ this . shared . applyNext ( prevProps , this . props , preserved ) ;
572
572
this . appliedNext = true ;
573
573
}
574
574
575
- this . shared . applyUserDefined ( this . props , preserved ) ;
575
+ this . shared . applyUserDefined ( prevProps , preserved ) ;
576
576
this . appliedUserDefined = true ;
577
577
}
578
578
@@ -736,45 +736,44 @@ export class UnControlled extends React.Component<IUnControlledCodeMirror, any>
736
736
}
737
737
738
738
/** @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 ) ) {
742
741
this . detached = false ;
743
- if ( this . props . editorDidAttach ) {
744
- this . props . editorDidAttach ( this . editor ) ;
742
+ if ( prevProps . editorDidAttach ) {
743
+ prevProps . editorDidAttach ( this . editor ) ;
745
744
}
746
745
}
747
746
748
- if ( ! this . detached && ( nextProps . detach === true ) ) {
747
+ if ( ! this . detached && ( this . props . detach === true ) ) {
749
748
this . detached = true ;
750
- if ( this . props . editorDidDetach ) {
751
- this . props . editorDidDetach ( this . editor ) ;
749
+ if ( prevProps . editorDidDetach ) {
750
+ prevProps . editorDidDetach ( this . editor ) ;
752
751
}
753
752
}
754
753
755
754
if ( SERVER_RENDERED || this . detached ) return ;
756
755
757
756
let preserved : IPreservedOptions = { cursor : null } ;
758
757
759
- if ( nextProps . value !== this . props . value ) {
758
+ if ( this . props . value !== prevProps . value ) {
760
759
this . hydrated = false ;
761
760
this . applied = false ;
762
761
this . appliedUserDefined = false ;
763
762
}
764
763
765
- if ( ! this . props . autoCursor && this . props . autoCursor !== undefined ) {
764
+ if ( ! prevProps . autoCursor && prevProps . autoCursor !== undefined ) {
766
765
preserved . cursor = this . editor . getDoc ( ) . getCursor ( ) ;
767
766
}
768
767
769
- this . hydrate ( nextProps ) ;
768
+ this . hydrate ( this . props ) ;
770
769
771
770
if ( ! this . applied ) {
772
- this . shared . apply ( this . props ) ;
771
+ this . shared . apply ( prevProps ) ;
773
772
this . applied = true ;
774
773
}
775
774
776
775
if ( ! this . appliedUserDefined ) {
777
- this . shared . applyUserDefined ( this . props , preserved ) ;
776
+ this . shared . applyUserDefined ( prevProps , preserved ) ;
778
777
this . appliedUserDefined = true ;
779
778
}
780
779
}
@@ -795,7 +794,7 @@ export class UnControlled extends React.Component<IUnControlledCodeMirror, any>
795
794
let update = true ;
796
795
797
796
if ( SERVER_RENDERED ) update = false ;
798
- if ( this . detached ) update = false ;
797
+ if ( this . detached && nextProps . detach ) update = false ;
799
798
800
799
return update ;
801
800
}
0 commit comments