Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 6991 | Rev 7007 | Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |

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

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

const NavSearch = () => {
  const history = useHistory()

  const { handleSubmit, register, setValue } = useForm()

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

  useEffect(() => {
    register('keyword', { required: true })
  }, [])

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

export default NavSearch