mirror of
https://github.com/MichaelMure/git-bug.git
synced 2024-12-15 02:01:43 +03:00
Replace switch to save lines of code :-)
This commit is contained in:
parent
3d5ac70f0a
commit
f980d9487e
@ -69,20 +69,11 @@ function Header() {
|
||||
const location = useLocation();
|
||||
|
||||
// Prevents error of invalid tab selection in <Tabs>
|
||||
// Will return a valid tab path or false if path is unkown.
|
||||
function highlightTab() {
|
||||
switch (location.pathname) {
|
||||
case '/':
|
||||
return '/';
|
||||
case '/code':
|
||||
return '/code';
|
||||
case '/pulls':
|
||||
return '/pulls';
|
||||
case '/settings':
|
||||
return '/settings';
|
||||
default:
|
||||
// using false as value for tabs will result in no selected tab
|
||||
return false;
|
||||
}
|
||||
const validTabs = ['/', '/code', '/pulls', '/settings'];
|
||||
const tab = validTabs.find((tabPath) => tabPath === location.pathname);
|
||||
return tab === undefined ? false : tab;
|
||||
}
|
||||
|
||||
return (
|
||||
|
Loading…
Reference in New Issue
Block a user