old-ybbond

My old site that was written with ReactJS
Log | Files | Refs | README | LICENSE | CC-LICENSE

react-router_v5.x.x.js (4310B)


      1 // flow-typed signature: 38d16d2099bb076f9f375a333a268246
      2 // flow-typed version: 45d63d67fa/react-router_v5.x.x/flow_>=v0.104.x
      3 
      4 declare module "react-router" {
      5   // NOTE: many of these are re-exported by react-router-dom and
      6   // react-router-native, so when making changes, please be sure to update those
      7   // as well.
      8   declare export type Location = {
      9     pathname: string,
     10     search: string,
     11     hash: string,
     12     ...
     13   };
     14 
     15   declare export type LocationShape = {
     16     pathname?: string,
     17     search?: string,
     18     hash?: string,
     19     ...
     20   };
     21 
     22   declare export type HistoryAction = "PUSH" | "REPLACE" | "POP";
     23 
     24   declare export type RouterHistory = {
     25     length: number,
     26     location: Location,
     27     action: HistoryAction,
     28     listen(
     29       callback: (location: Location, action: HistoryAction) => void
     30     ): () => void,
     31     push(path: string | LocationShape, state?: any): void,
     32     replace(path: string | LocationShape, state?: any): void,
     33     go(n: number): void,
     34     goBack(): void,
     35     goForward(): void,
     36     canGo?: (n: number) => boolean,
     37     block(
     38       callback: string | (location: Location, action: HistoryAction) => ?string
     39     ): () => void,
     40     ...
     41   };
     42 
     43   declare export type Match = {
     44     params: { [key: string]: ?string, ... },
     45     isExact: boolean,
     46     path: string,
     47     url: string,
     48     ...
     49   };
     50 
     51   declare export type ContextRouter = {|
     52     history: RouterHistory,
     53     location: Location,
     54     match: Match,
     55     staticContext?: StaticRouterContext
     56   |};
     57 
     58   declare export type GetUserConfirmation = (
     59     message: string,
     60     callback: (confirmed: boolean) => void
     61   ) => void;
     62 
     63   declare type StaticRouterContext = { url?: string, ... };
     64 
     65   declare export class StaticRouter extends React$Component<{
     66     basename?: string,
     67     location?: string | Location,
     68     context: StaticRouterContext,
     69     children?: React$Node,
     70     ...
     71   }> {}
     72 
     73   declare export class MemoryRouter extends React$Component<{
     74     initialEntries?: Array<LocationShape | string>,
     75     initialIndex?: number,
     76     getUserConfirmation?: GetUserConfirmation,
     77     keyLength?: number,
     78     children?: React$Node,
     79     ...
     80   }> {}
     81 
     82   declare export class Router extends React$Component<{
     83     history: RouterHistory,
     84     children?: React$Node,
     85     ...
     86   }> {}
     87 
     88   declare export class Prompt extends React$Component<{
     89     message: string | ((location: Location) => string | true),
     90     when?: boolean,
     91     ...
     92   }> {}
     93 
     94   declare export class Redirect extends React$Component<{|
     95     to: string | LocationShape,
     96     push?: boolean,
     97     from?: string,
     98     exact?: boolean,
     99     strict?: boolean
    100   |}> {}
    101 
    102 
    103   declare export class Route extends React$Component<{|
    104     component?: React$ComponentType<*>,
    105     render?: (router: ContextRouter) => React$Node,
    106     children?: React$ComponentType<ContextRouter> | React$Node,
    107     path?: string | Array<string>,
    108     exact?: boolean,
    109     strict?: boolean,
    110     location?: LocationShape,
    111     sensitive?: boolean
    112   |}> {}
    113 
    114   declare export class Switch extends React$Component<{|
    115     children?: React$Node,
    116     location?: Location
    117   |}> {}
    118 
    119   declare export function withRouter<P>(
    120     Component: React$ComponentType<{| ...ContextRouter, ...P |}>
    121   ): React$ComponentType<P>;
    122 
    123   declare type MatchPathOptions = {
    124     path?: string | string[],
    125     exact?: boolean,
    126     strict?: boolean,
    127     sensitive?: boolean,
    128     ...
    129   };
    130 
    131   declare export function matchPath(
    132     pathname: string,
    133     options?: MatchPathOptions | string | string[]
    134   ): null | Match;
    135 
    136   declare export function useHistory(): $PropertyType<ContextRouter, 'history'>;
    137   declare export function useLocation(): $PropertyType<ContextRouter, 'location'>;
    138   declare export function useParams(): $PropertyType<$PropertyType<ContextRouter, 'match'>, 'params'>;
    139   declare export function useRouteMatch(path?: MatchPathOptions | string | string[]): $PropertyType<ContextRouter, 'match'>;
    140 
    141   declare export function generatePath(pattern?: string, params?: {...}): string;
    142 
    143   declare export default {
    144     StaticRouter: typeof StaticRouter,
    145     MemoryRouter: typeof MemoryRouter,
    146     Router: typeof Router,
    147     Prompt: typeof Prompt,
    148     Redirect: typeof Redirect,
    149     Route: typeof Route,
    150     Switch: typeof Switch,
    151     withRouter: typeof withRouter,
    152     matchPath: typeof matchPath,
    153     generatePath: typeof generatePath,
    154     ...
    155   };
    156 }