Created
April 26, 2021 13:49
-
-
Save brutalzinn/efe0cc18350784fad60168ec0a45cc31 to your computer and use it in GitHub Desktop.
bootcamp title correction
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const history = useHistory(); | |
useEffect(() => { | |
return history.listen((location) => { | |
let nomeDaPagina="Nome do projeto" | |
let _title = location.pathname.replace('/', '') | |
_title = _title.indexOf('/') > 0 ? _title.substring(0, _title.indexOf('/')) : _title | |
switch(_title.toUpperCase()){ | |
case '': | |
_title = `${nomeDaPagina}-Início` | |
break; | |
case 'CADASTRO': | |
_title = `${nomeDaPagina}-Cadastro` | |
break; | |
default: _title = 'Erro' | |
break; | |
} | |
document.title = _title; | |
console.log(`Você está na página ${location.pathname}`) | |
}) | |
},[history]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment