]> cat aescling's git repositories - mastodon.git/commitdiff
[Glitch] Fix some React warnings
authorEugen Rochko <eugen@zeonfederated.com>
Fri, 7 Jun 2019 15:15:18 +0000 (17:15 +0200)
committerThibG <thib@sitedethib.com>
Thu, 13 Jun 2019 20:15:31 +0000 (22:15 +0200)
Port cc8f6b3cdaca81be99875c27002e0280d1d88191 to glitch-soc

Signed-off-by: Thibaut Girka <thib@sitedethib.com>
app/javascript/flavours/glitch/components/autosuggest_textarea.js
app/javascript/flavours/glitch/features/compose/components/compose_form.js

index 7a6b9d8ac0fc746d3ed06d2f4c577ec9d7aebadb..bbe0ffcbe0dd4242cf8f78157958056959f1238e 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 52aa79b3506a538c2790f45556e4546d3f21fc95..71fd891144de4609dbf943b0f1f02fa7ba156bf6 100644 (file)
@@ -28,10 +28,6 @@ const messages = defineMessages({
 export default @injectIntl
 class ComposeForm extends ImmutablePureComponent {
 
-  setRef = c => {
-    this.composeForm = c;
-  };
-
   static contextTypes = {
     router: PropTypes.object,
   };
@@ -145,6 +141,10 @@ class ComposeForm extends ImmutablePureComponent {
     }
   }
 
+  setRef = c => {
+    this.composeForm = c;
+  };
+
   //  Inserts an emoji at the caret.
   handleEmoji = (data) => {
     const { textarea: { selectionStart } } = this;
@@ -213,7 +213,9 @@ class ComposeForm extends ImmutablePureComponent {
   }
 
   handleFocus = () => {
-    this.composeForm.scrollIntoView();
+    if (this.composeForm) {
+      this.composeForm.scrollIntoView();
+    }
   }
 
   //  This statement does several things: