3434- [ Route types] ( #route-types )
3535 - [ Public route] ( #public-route )
3636 - [ Private route] ( #private-route )
37+ - [ Hybrid route] ( #hybrid-route )
3738- [ Control visibility of components] ( #control-visibility-of-components )
3839- [ Contributing] ( #contributing )
3940- [ Versioning] ( #versioning )
@@ -147,34 +148,34 @@ The route components are based on `<Route />` component of [react-router-dom](ht
147148
148149The route can only be accessed if a user is not authenticated. If accessed after authentication, the user will be redirected ` / ` route.
149150
150- ``` js
151- import { Switch } from ' react-router-dom'
151+ ``` tsx
152+ import { Routes } from ' react-router-dom'
152153import { PublicRoute } from ' src/router/PublicRoute'
153154
154155const SampleComponent = () => <div >Sample component</div >
155156
156157export const Routes = () => (
157- < Switch >
158+ <Routes >
158159 <PublicRoute
159160 path = " /login"
160161 component = { SampleComponent }
161162 />
162- < / Switch >
163+ </Routes >
163164)
164165```
165166
166167### Private route
167168
168- The route can only be accessed if a user is authenticated. Use permission props to access control.
169+ The route can only be accessed if a user is authenticated. Use permission props (returned by the API) to access the control.
169170
170- ``` js
171- import { Switch } from ' react-router-dom'
171+ ``` tsx
172+ import { Routes } from ' react-router-dom'
172173import { PrivateRoute } from ' src/router/PrivateRoute'
173174
174175const SampleComponent = () => <div >Sample component</div >
175176
176177export const Routes = () => (
177- < Switch >
178+ <Routes >
178179 { /*
179180 allow route access if the user has the permissions
180181 `users.list` and `users.create`
@@ -184,15 +185,32 @@ export const Routes = () => (
184185 component = { SampleComponent }
185186 permissions = { [' users.list' , ' users.create' ]}
186187 />
187- < / Switch>
188+ </Routes >
189+ )
190+ ```
191+
192+ ### Hybrid route
193+
194+ The route can be accessed if a user is authenticated or not. Use ` Route ` component.
195+
196+ ``` tsx
197+ import { Routes } from ' react-router-dom'
198+ import { PrivateRoute } from ' src/router/PrivateRoute'
199+
200+ const SampleComponent = () => <div >Sample component</div >
201+
202+ export const Routes = () => (
203+ <Routes >
204+ <Route path = " /contact" element = { <SampleComponent />} />
205+ </Routes >
188206)
189207```
190208
191209## Control visibility of components
192210
193211Use the ` CanAccess ` component and pass ` permissions ` props to control the visibility of a component.
194212
195- ``` js
213+ ``` tsx
196214import { CanAccess } from ' src/components'
197215
198216export function NavBar () {
0 commit comments