Преглед изворни кода

typeahead.getInstance() --> React.createRef()

Shun Miyazawa пре 4 година
родитељ
комит
9c9c28a87a
1 измењених фајлова са 4 додато и 2 уклоњено
  1. 4 2
      packages/app/src/components/Page/TagsInput.jsx

+ 4 - 2
packages/app/src/components/Page/TagsInput.jsx

@@ -26,13 +26,15 @@ class TagsInput extends React.Component {
       defaultPageTags: this.props.tags,
     };
 
+    this.tagsInput = React.createRef();
+
     this.handleChange = this.handleChange.bind(this);
     this.handleSearch = this.handleSearch.bind(this);
     this.handleSelect = this.handleSelect.bind(this);
   }
 
   componentDidMount() {
-    this.typeahead.getInstance().focus();
+    this.tagsInput.current.focus();
   }
 
   handleChange(selected) {
@@ -69,7 +71,7 @@ class TagsInput extends React.Component {
       <div className="tag-typeahead">
         <AsyncTypeahead
           id="tag-typeahead-asynctypeahead"
-          ref={(typeahead) => { this.typeahead = typeahead }}
+          ref={this.tagsInput}
           caseSensitive={false}
           defaultSelected={this.state.defaultPageTags}
           isLoading={this.state.isLoading}