File tree Expand file tree Collapse file tree 2 files changed +7
-2
lines changed
components/NoDirectAccessRoutes Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change 1
1
import { Navigate , Outlet , useLocation } from "react-router-dom" ;
2
+ import { LocationState } from "../../hooks/useAppNavigate" ;
2
3
3
4
const NoDirectAccessRoutes : React . FC = ( ) => {
4
5
const location = useLocation ( ) ;
5
6
6
- if ( location . state ?. from !== "app-navigation" ) {
7
+ if ( ( location . state as LocationState ) ?. from !== "app-navigation" ) {
7
8
return < Navigate to = "/home" replace /> ;
8
9
}
9
10
Original file line number Diff line number Diff line change 1
1
import { useNavigate } from "react-router-dom" ;
2
2
3
+ export interface LocationState {
4
+ from : string ;
5
+ }
6
+
3
7
export const useAppNavigate = ( ) => {
4
8
const navigate = useNavigate ( ) ;
5
9
6
10
const appNavigate = ( path : string ) => {
7
11
navigate ( path , {
8
12
replace : location . pathname !== "/home" ,
9
- state : { from : "app-navigation" } ,
13
+ state : { from : "app-navigation" } as LocationState ,
10
14
} ) ;
11
15
} ;
12
16
You can’t perform that action at this time.
0 commit comments