Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 7007 | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |

import React, { useState } from 'react'
import { useForm } from 'react-hook-form'
import { useHistory } from 'react-router-dom'

import SearchInput from '../../../UI/SearchInput'

const NavSearch = () => {
  const [keyword, setKeyword] = useState('')
  const history = useHistory()

  const { handleSubmit } = useForm()

  const onSubmit = handleSubmit(() => {
    history.replace(`/search/entity/user?keyword=${keyword}`)
    setKeyword('')
  })

  return (
    <SearchInput
      as="form"
      onSubmit={onSubmit}
      onChange={(e) => setKeyword(e.target.value)}
      value={keyword}
    />
  )
}

export default NavSearch