@@ -81,14 +81,6 @@ export default class ReactCodeMirror extends Component<ICodeMirror, ICodeMirrorS
81
81
// public editor!: Doc | Editor | EditorFromTextArea | Editor;
82
82
public constructor ( props : Readonly < ICodeMirror > ) {
83
83
super ( props ) ;
84
- }
85
- public render ( ) {
86
- return (
87
- < textarea ref = { ( instance : HTMLTextAreaElement ) => this . textarea = instance } />
88
- ) ;
89
- }
90
-
91
- public componentWillMount ( ) {
92
84
if ( SERVER_RENDERED ) {
93
85
return ;
94
86
}
@@ -97,6 +89,11 @@ export default class ReactCodeMirror extends Component<ICodeMirror, ICodeMirrorS
97
89
this . props . editorWillMount ( ) ;
98
90
}
99
91
}
92
+ public render ( ) {
93
+ return (
94
+ < textarea ref = { ( instance : HTMLTextAreaElement ) => this . textarea = instance } />
95
+ ) ;
96
+ }
100
97
101
98
public componentDidMount ( ) {
102
99
if ( SERVER_RENDERED ) {
@@ -116,10 +113,9 @@ export default class ReactCodeMirror extends Component<ICodeMirror, ICodeMirrorS
116
113
117
114
this . renderCodeMirror ( this . props ) ;
118
115
}
119
- public UNSAFE_componentWillReceiveProps ( nextPros : ICodeMirror ) {
120
- if ( nextPros . value !== this . props . value || nextPros . width !== this . props . width || nextPros . height !== this . props . height ) {
121
- this . renderCodeMirror ( nextPros ) ;
122
- }
116
+
117
+ componentDidUpdate ( ) {
118
+ this . renderCodeMirror ( this . props ) ;
123
119
}
124
120
125
121
public shouldComponentUpdate ( nextProps : ICodeMirror , nextState : ICodeMirrorState ) {
@@ -128,7 +124,7 @@ export default class ReactCodeMirror extends Component<ICodeMirror, ICodeMirrorS
128
124
|| nextProps . height !== this . props . height
129
125
|| nextProps . width !== this . props . width ;
130
126
}
131
- // 将props中所有的事件处理函数映射并保存
127
+ // 将 props 中所有的事件处理函数映射并保存
132
128
public getEventHandleFromProps ( ) : IEventDict {
133
129
const propNames = Object . keys ( this . props ) ;
134
130
const eventHandle = propNames . filter ( ( prop ) => {
0 commit comments