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 11import { Navigate , Outlet , useLocation } from "react-router-dom" ;
2+ import { LocationState } from "../../hooks/useAppNavigate" ;
23
34const NoDirectAccessRoutes : React . FC = ( ) => {
45 const location = useLocation ( ) ;
56
6- if ( location . state ?. from !== "app-navigation" ) {
7+ if ( ( location . state as LocationState ) ?. from !== "app-navigation" ) {
78 return < Navigate to = "/home" replace /> ;
89 }
910
Original file line number Diff line number Diff line change 11import { useNavigate } from "react-router-dom" ;
22
3+ export interface LocationState {
4+ from : string ;
5+ }
6+
37export const useAppNavigate = ( ) => {
48 const navigate = useNavigate ( ) ;
59
610 const appNavigate = ( path : string ) => {
711 navigate ( path , {
812 replace : location . pathname !== "/home" ,
9- state : { from : "app-navigation" } ,
13+ state : { from : "app-navigation" } as LocationState ,
1014 } ) ;
1115 } ;
1216
You can’t perform that action at this time.
0 commit comments