clapper / src /lib /hooks /useTitle.ts
jbilcke-hf's picture
jbilcke-hf HF staff
add linter and prettifier
c1f12bf
raw
history blame
No virus
362 Bytes
import { useState, useEffect } from 'react'
export const useTitle = (): {
title: string
changeTitle: (newTitle: string) => void
} => {
const [title, setTitle] = useState<string>(document.title)
useEffect(() => {
document.title = title
}, [title])
const changeTitle = (newTitle: string) => setTitle(newTitle)
return { title, changeTitle }
}