SearchModalTriggerinput.tsx 661 B

12345678910111213141516171819202122232425262728293031
  1. import React, {
  2. useCallback,
  3. } from 'react';
  4. import { useSearchModal } from '../../features/search/client/stores/search';
  5. type Props = {
  6. keywordOnInit: string,
  7. };
  8. export const SearchModalTriggerinput: React.FC<Props> = (props: Props) => {
  9. const { keywordOnInit } = props;
  10. const { open: openSearchModal } = useSearchModal();
  11. const inputClickHandler = useCallback(() => {
  12. openSearchModal(keywordOnInit);
  13. }, [openSearchModal, keywordOnInit]);
  14. return (
  15. <div>
  16. <input
  17. className="form-control"
  18. type="input"
  19. value={keywordOnInit}
  20. onClick={inputClickHandler}
  21. readOnly
  22. />
  23. </div>
  24. );
  25. };