import React , { useEffect , useState } from 'react' ; import { Helmet } from 'react-helmet' ; export function useDeferredState < T > ( duration = 1000 , initialValue ) { const [ response , setResponse ] = useState ( initialValue ) ; const [ innerValue , setInnerValue ] = useState ( initialValue ) ; useEffect ( ( ) => { const fn = setTimeout ( ( ) => { setResponse ( innerValue ) ; } , duration ) ; return ( ) : void => { clearTimeout ( fn ) ; } ; } , [ duration , innerValue ] ) ; return [ response , setInnerValue ] ; } export function useOpenSearch ( xmlPath ) { return ( ) => ( < Helmet > < link rel = "search" type = "application/opensearchdescription+xml" title = "namae" href = { xmlPath } / > < /Helmet>); }