mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-18 00:54:43 -04:00
Replace empty components with hooks (#666)
This commit is contained in:
parent
9e9108ec9a
commit
0d2c2fe0ee
5 changed files with 19 additions and 24 deletions
11
src/hooks/common/use-document-title.ts
Normal file
11
src/hooks/common/use-document-title.ts
Normal file
|
@ -0,0 +1,11 @@
|
|||
import { useEffect } from 'react'
|
||||
import { useSelector } from 'react-redux'
|
||||
import { ApplicationState } from '../../redux'
|
||||
|
||||
export const useDocumentTitle = (title?: string):void => {
|
||||
const brandingName = useSelector((state: ApplicationState) => state.config.branding.name)
|
||||
|
||||
useEffect(() => {
|
||||
document.title = `${title ? title + ' - ' : ''}HedgeDoc ${brandingName ? ` @ ${brandingName}` : ''}`
|
||||
}, [brandingName, title])
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue