]> cat aescling's git repositories - mastodon.git/commitdiff
Fix some React warnings (#10989)
authorEugen Rochko <eugen@zeonfederated.com>
Fri, 7 Jun 2019 15:15:18 +0000 (17:15 +0200)
committerGitHub <noreply@github.com>
Fri, 7 Jun 2019 15:15:18 +0000 (17:15 +0200)
app/javascript/mastodon/components/autosuggest_textarea.js
app/javascript/mastodon/features/compose/components/compose_form.js

index 4c50294baee512af48ddff2bf548fdcc9c64997e..b070fe3e5156d65353c46cce00cf8fb7f0509a3d 100644 (file)
@@ -201,7 +201,7 @@ export default class AutosuggestTextarea extends ImmutablePureComponent {
     }
 
     return [
-      <div className='compose-form__autosuggest-wrapper'>
+      <div className='compose-form__autosuggest-wrapper' key='autosuggest-wrapper'>
         <div className='autosuggest-textarea'>
           <label>
             <span style={{ display: 'none' }}>{placeholder}</span>
@@ -226,7 +226,8 @@ export default class AutosuggestTextarea extends ImmutablePureComponent {
         </div>
         {children}
       </div>,
-      <div className='autosuggest-textarea__suggestions-wrapper'>
+
+      <div className='autosuggest-textarea__suggestions-wrapper' key='suggestions-wrapper'>
         <div className={`autosuggest-textarea__suggestions ${suggestionsHidden || suggestions.isEmpty() ? '' : 'autosuggest-textarea__suggestions--visible'}`}>
           {suggestions.map(this.renderSuggestion)}
         </div>
index 531b288666cba54784e90e6e7087e6a5c3753040..558b7068baec21bb489ffc0009e3bfdca830ac26 100644 (file)
@@ -33,10 +33,6 @@ const messages = defineMessages({
 export default @injectIntl
 class ComposeForm extends ImmutablePureComponent {
 
-  setRef = c => {
-    this.composeForm = c;
-  };
-
   static contextTypes = {
     router: PropTypes.object,
   };
@@ -119,7 +115,9 @@ class ComposeForm extends ImmutablePureComponent {
   }
 
   handleFocus = () => {
-    this.composeForm.scrollIntoView();
+    if (this.composeForm) {
+      this.composeForm.scrollIntoView();
+    }
   }
 
   componentDidUpdate (prevProps) {
@@ -163,6 +161,10 @@ class ComposeForm extends ImmutablePureComponent {
     this.spoilerText = c;
   }
 
+  setRef = c => {
+    this.composeForm = c;
+  };
+
   handleEmojiPick = (data) => {
     const { text }     = this.props;
     const position     = this.autosuggestTextarea.textarea.selectionStart;