@@ -81,14 +81,6 @@ export default class ReactCodeMirror extends Component<ICodeMirror, ICodeMirrorS
8181 // public editor!: Doc | Editor | EditorFromTextArea | Editor;
8282 public constructor ( props : Readonly < ICodeMirror > ) {
8383 super ( props ) ;
84- }
85- public render ( ) {
86- return (
87- < textarea ref = { ( instance : HTMLTextAreaElement ) => this . textarea = instance } />
88- ) ;
89- }
90-
91- public componentWillMount ( ) {
9284 if ( SERVER_RENDERED ) {
9385 return ;
9486 }
@@ -97,6 +89,11 @@ export default class ReactCodeMirror extends Component<ICodeMirror, ICodeMirrorS
9789 this . props . editorWillMount ( ) ;
9890 }
9991 }
92+ public render ( ) {
93+ return (
94+ < textarea ref = { ( instance : HTMLTextAreaElement ) => this . textarea = instance } />
95+ ) ;
96+ }
10097
10198 public componentDidMount ( ) {
10299 if ( SERVER_RENDERED ) {
@@ -116,10 +113,9 @@ export default class ReactCodeMirror extends Component<ICodeMirror, ICodeMirrorS
116113
117114 this . renderCodeMirror ( this . props ) ;
118115 }
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 ) ;
123119 }
124120
125121 public shouldComponentUpdate ( nextProps : ICodeMirror , nextState : ICodeMirrorState ) {
@@ -128,7 +124,7 @@ export default class ReactCodeMirror extends Component<ICodeMirror, ICodeMirrorS
128124 || nextProps . height !== this . props . height
129125 || nextProps . width !== this . props . width ;
130126 }
131- // 将props中所有的事件处理函数映射并保存
127+ // 将 props 中所有的事件处理函数映射并保存
132128 public getEventHandleFromProps ( ) : IEventDict {
133129 const propNames = Object . keys ( this . props ) ;
134130 const eventHandle = propNames . filter ( ( prop ) => {
0 commit comments