1- // flow-typed signature: a619baa45c5e804d22612d501f770766
2- // flow-typed version: c1a3d567a9 /react-router-dom_v5 .x.x/flow_>=v0.104.x
1+ // flow-typed signature: 78dc7c448940b4fd3611832c7db0db62
2+ // flow-typed version: df736c39bb /react-router-dom_v6 .x.x/flow_>=v0.104.x
33
44declare module "react-router-dom" {
55 declare export var BrowserRouter : React$ComponentType < { |
@@ -128,31 +128,40 @@ declare module "react-router-dom" {
128128 children ?: React$Node
129129 | } >
130130
131+ declare export var Route : React$ComponentType < { |
132+ caseSensitive ? : boolean ,
133+ children ?: React$Node ,
134+ element ?: React$Element < any > | null ,
135+ index ?: boolean ,
136+ path ?: string ,
137+ | } >
138+
131139 declare export var Prompt : React$ComponentType < { |
132140 message : string | ( ( location : Location ) => string | boolean ) ,
133141 when ?: boolean
134142 | } >
135143
136- declare export var Redirect : React$ComponentType < { |
137- to : string | LocationShape ,
138- push ?: boolean ,
139- from ?: string ,
140- exact ?: boolean ,
141- strict ?: boolean
144+ declare export var Outlet : React$ComponentType < { |
145+ context ?: mixed ;
142146 | } >
143147
144- declare export var Route : React$ComponentType < { |
145- component ?: React$ComponentType < * > ,
146- render ?: ( router : ContextRouter ) => React$Node ,
147- children ?: React$ComponentType < ContextRouter > | React$Node ,
148- path ?: string | Array < string > ,
149- exact ?: boolean ,
150- strict ?: boolean ,
151- location ?: LocationShape ,
152- sensitive ?: boolean
153- | } >
148+ declare export var useNavigate : ( ) => (
149+ & ( (
150+ to : To ,
151+ options ?: { |
152+ replace ?: boolean , state ? : any ,
153+ | } ,
154+ ) => void )
155+ & ( ( delta : number ) => void )
156+ ) ;
154157
155- declare export var Switch : React$ComponentType < { |
158+ declare export var Navigate : ( props : { |
159+ to : To ;
160+ replace ?: boolean ;
161+ state ?: any ;
162+ | } ) = > null ;
163+
164+ declare export var Routes : React$ComponentType < { |
156165 children ? : React$Node ,
157166 location ?: Location
158167 | } >
@@ -177,8 +186,110 @@ declare module "react-router-dom" {
177186
178187 declare export function useHistory ( ) : $PropertyType < ContextRouter , 'history' > ;
179188 declare export function useLocation ( ) : $PropertyType < ContextRouter , 'location' > ;
189+ declare export function useOutletContext < T > (): T;
180190 declare export function useParams< Params = $PropertyType < $PropertyType < ContextRouter , 'match '> , 'params'>> ( ) : Params ;
181191 declare export function useRouteMatch ( path ?: MatchPathOptions | string | string [ ] ) : $PropertyType < ContextRouter , 'match' > ;
182192
183193 declare export function generatePath ( pattern ?: string , params ?: { + [ string ] : mixed , ... } ) : string ;
194+
195+ declare type RouteObject = { |
196+ caseSensitive ?: boolean ,
197+ children ?: Array < RouteObject > ,
198+ element ?: React$Node ,
199+ index ?: boolean ,
200+ path ?: string ,
201+ | } ;
202+
203+ declare export function createRoutesFromChildren (
204+ children : React$Node ,
205+ ) : Array < RouteObject > ;
206+
207+ declare type Params < Key : string > = {
208+ + [ key : Key ] : string | void ;
209+ } ;
210+
211+ declare type RouteMatch < ParamKey : string > = { |
212+ params : Params < ParamKey > ,
213+ pathname : string ,
214+ route : RouteObject ,
215+ | } ;
216+
217+ declare export function matchRoutes (
218+ routes : Array < RouteObject > ,
219+ location : LocationShape | string ,
220+ basename ?: string ,
221+ ) : Array < RouteMatch < string >> | null ;
222+
223+ declare export function renderMatches (
224+ matches : Array < RouteMatch < string >> | null ,
225+ ) : React$Element < any > | null ;
226+
227+ declare type PathPattern = { |
228+ path : string ,
229+ caseSensitive ?: boolean ,
230+ end ?: boolean ,
231+ | } ;
232+
233+ declare type PathMatch < ParamKey : string = string > = { |
234+ params : Params < ParamKey > ,
235+ pathname : string ,
236+ pattern : PathPattern ,
237+ | } ;
238+
239+ declare export function matchPath < ParamKey : string = string > (
240+ pattern: PathPattern | string,
241+ pathname: string,
242+ ): PathMatch< ParamKey > | null;
243+
244+ declare type To = LocationShape | string;
245+
246+ declare type Path = { |
247+ pathname : string ,
248+ search : string ,
249+ hash : string ,
250+ | } ;
251+
252+ declare export function resolvePath(
253+ to: To,
254+ fromPathname?: string
255+ ): Path;
256+
257+ declare export function useHref(to: To): string;
258+
259+ declare export function useInRouterContext(): boolean;
260+
261+ declare export function useNavigationType(): 'POP' | 'PUSH' | 'REPLACE';
262+
263+ declare export function useMatch< ParamKey : string = string > (
264+ pattern: PathPattern | string
265+ ): PathMatch< ParamKey > | null;
266+
267+ declare export function useOutlet< T = any > (): React$Element< T > | null;
268+
269+ declare export function useRoutes< T = any > (
270+ routes: Array< RouteObject > ,
271+ location?: LocationShape | string,
272+ ): React$Element< T > | null;
273+
274+ declare export function useSearchParams(
275+ defaultInit?: URLSearchParamsInit
276+ ): [URLSearchParams, SetURLSearchParams];
277+
278+ declare type URLSearchParamsInit =
279+ | string
280+ | Array< [ string , string ] >
281+ | { [ key : string ] : string | Array < string > , ... }
282+ | URLSearchParams;
283+
284+ declare type SetURLSearchParams = (
285+ nextInit?: URLSearchParamsInit,
286+ navigateOpts?: { |
287+ replace ? : boolean ,
288+ state ? : any ,
289+ | }
290+ ) => void ;
291+
292+ declare export function createSearchParams (
293+ init ?: URLSearchParamsInit ,
294+ ) : URLSearchParams ;
184295}
0 commit comments