forked from cloudbees-io/react-fm-example
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathNav.tsx
More file actions
29 lines (27 loc) · 877 Bytes
/
Nav.tsx
File metadata and controls
29 lines (27 loc) · 877 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// components/NavBar.js
import { Link } from 'react-router-dom'
import { useFeatureFlag } from './useFeatureFlag'
import { customRoutes } from './App'
import { namespaceFlags } from './feature-management/flags'
export const Nav = () => {
const enabledRoutes = customRoutes.filter((route) => {
const routeFlag = route.featureFlag
? route.featureFlag.namespace === 'routes' && route.featureFlag.flag === 'about'
? true
: useFeatureFlag(
namespaceFlags[route.featureFlag.namespace][route.featureFlag.flag]
)
: true
return routeFlag
})
return (
<nav>
{enabledRoutes.map((route, index) => (
<div key={index} style={{ display: 'inline' }}>
<Link to={route.path}>{route.label}</Link>
{index < enabledRoutes.length - 1 && <span> | </span>}
</div>
))}
</nav>
)
}