Yuki Takei пре 4 година
родитељ
комит
5cef3d1eba
1 измењених фајлова са 5 додато и 18 уклоњено
  1. 5 18
      packages/app/src/components/SearchForm.tsx

+ 5 - 18
packages/app/src/components/SearchForm.tsx

@@ -4,11 +4,8 @@ import React, {
 } from 'react';
 } from 'react';
 import { useTranslation } from 'react-i18next';
 import { useTranslation } from 'react-i18next';
 
 
-import AppContainer from '~/client/services/AppContainer';
 import { IFocusable } from '~/client/interfaces/focusable';
 import { IFocusable } from '~/client/interfaces/focusable';
 
 
-import { withUnstatedContainers } from './UnstatedUtils';
-
 import SearchTypeahead from './SearchTypeahead';
 import SearchTypeahead from './SearchTypeahead';
 
 
 
 
@@ -82,7 +79,7 @@ const SearchFormHelp: FC<SearchFormHelpProps> = (props: SearchFormHelpProps) =>
 
 
 
 
 type Props = {
 type Props = {
-  appContainer: AppContainer,
+  isSearchServiceReachable: boolean,
 
 
   dropup?: boolean,
   dropup?: boolean,
   keyword?: string,
   keyword?: string,
@@ -94,7 +91,7 @@ type Props = {
 const SearchForm: ForwardRefRenderFunction<IFocusable, Props> = (props: Props, ref) => {
 const SearchForm: ForwardRefRenderFunction<IFocusable, Props> = (props: Props, ref) => {
   const { t } = useTranslation();
   const { t } = useTranslation();
   const {
   const {
-    appContainer, dropup, onSubmit, onInputChange,
+    isSearchServiceReachable, dropup, onSubmit, onInputChange,
   } = props;
   } = props;
 
 
   const [searchError, setSearchError] = useState<Error | null>(null);
   const [searchError, setSearchError] = useState<Error | null>(null);
@@ -112,10 +109,7 @@ const SearchForm: ForwardRefRenderFunction<IFocusable, Props> = (props: Props, r
     },
     },
   }));
   }));
 
 
-  const config = appContainer.getConfig();
-  const isReachable = config.isSearchServiceReachable;
-
-  const placeholder = isReachable
+  const placeholder = isSearchServiceReachable
     ? 'Search ...'
     ? 'Search ...'
     : 'Error on Search Service';
     : 'Error on Search Service';
 
 
@@ -134,17 +128,10 @@ const SearchForm: ForwardRefRenderFunction<IFocusable, Props> = (props: Props, r
       onSearchError={err => setSearchError(err)}
       onSearchError={err => setSearchError(err)}
       onBlur={() => setShownHelp(false)}
       onBlur={() => setShownHelp(false)}
       onFocus={() => setShownHelp(true)}
       onFocus={() => setShownHelp(true)}
-      helpElement={<SearchFormHelp isShownHelp={isShownHelp} isReachable={isReachable} />}
+      helpElement={<SearchFormHelp isShownHelp={isShownHelp} isReachable={isSearchServiceReachable} />}
       keywordOnInit={props.keyword}
       keywordOnInit={props.keyword}
     />
     />
   );
   );
 };
 };
 
 
-const ForwardedSearchForm = forwardRef(SearchForm);
-
-/**
- * Wrapper component for using unstated
- */
-const SearchFormWrapper = withUnstatedContainers(ForwardedSearchForm, [AppContainer]);
-
-export default SearchFormWrapper;
+export default forwardRef(SearchForm);