Ver Fonte

refactor SearchTypeahead

Yuki Takei há 4 anos atrás
pai
commit
ada1e62c07
1 ficheiros alterados com 3 adições e 8 exclusões
  1. 3 8
      packages/app/src/components/SearchTypeahead.jsx

+ 3 - 8
packages/app/src/components/SearchTypeahead.jsx

@@ -7,7 +7,7 @@ import { AsyncTypeahead } from 'react-bootstrap-typeahead';
 import { UserPicture, PageListMeta, PagePathLabel } from '@growi/ui';
 import { UserPicture, PageListMeta, PagePathLabel } from '@growi/ui';
 
 
 import AppContainer from '~/client/services/AppContainer';
 import AppContainer from '~/client/services/AppContainer';
-import { withUnstatedContainers } from './UnstatedUtils';
+import { apiGet } from '~/client/util/apiv1-client';
 
 
 class SearchTypeahead extends React.Component {
 class SearchTypeahead extends React.Component {
 
 
@@ -80,7 +80,7 @@ class SearchTypeahead extends React.Component {
 
 
     this.setState({ isLoading: true });
     this.setState({ isLoading: true });
 
 
-    this.props.appContainer.apiGet('/search', { q: keyword })
+    apiGet('/search', { q: keyword })
       .then((res) => { this.onSearchSuccess(res) })
       .then((res) => { this.onSearchSuccess(res) })
       .catch((err) => { this.onSearchError(err) });
       .catch((err) => { this.onSearchError(err) });
   }
   }
@@ -229,11 +229,6 @@ class SearchTypeahead extends React.Component {
 
 
 }
 }
 
 
-/**
- * Wrapper component for using unstated
- */
-const SearchTypeaheadWrapper = withUnstatedContainers(SearchTypeahead, [AppContainer]);
-
 /**
 /**
  * Properties
  * Properties
  */
  */
@@ -271,4 +266,4 @@ SearchTypeahead.defaultProps = {
   onInputChange: () => {},
   onInputChange: () => {},
 };
 };
 
 
-export default SearchTypeaheadWrapper;
+export default SearchTypeahead;