File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -25,10 +25,7 @@ export {
2525export { useRouteError } from "./useRouteError" ;
2626export { handleLazyImportError } from "./handleLazyImportError" ;
2727
28- type StateCandidate = { from : string } | Record < string , unknown > ;
29-
30- export const useLocationState = ( ) =>
31- ( useLocation ( ) . state as StateCandidate ) ?? { } ;
28+ export const useLocationState = ( ) => useLocation ( ) . state ?? { } ;
3229
3330export const generatePath = (
3431 path : string ,
Original file line number Diff line number Diff line change 1+ // eslint-disable-next-line no-restricted-imports
2+ import type {
3+ NavigateOptions as RRNavigateOptions ,
4+ Location as RRLocation ,
5+ To ,
6+ } from "react-router" ;
7+
8+ declare module "react-router" {
9+ interface NavigateState {
10+ from ?: string ;
11+ [ key : string ] : unknown ;
12+ }
13+
14+ interface LocationWithState extends Omit < RRLocation , "state" > {
15+ state ?: NavigateState ;
16+ }
17+
18+ interface NavigateOptions extends Omit < RRNavigateOptions , "state" > {
19+ state ?: NavigateState ;
20+ }
21+
22+ interface NavigateFunction {
23+ ( to : To , options ?: NavigateOptions ) : void | Promise < void > ;
24+ ( delta : number ) : void | Promise < void > ;
25+ }
26+
27+ function useLocation ( ) : LocationWithState ;
28+ function useNavigate ( ) : NavigateFunction ;
29+ }
You can’t perform that action at this time.
0 commit comments