UNPKG

1.61 kBJavaScriptView Raw
1if (__DEV__) {
2 if (typeof window !== "undefined") {
3 const global = window;
4 const key = "__react_router_build__";
5 const buildNames = { cjs: "CommonJS", esm: "ES modules", umd: "UMD" };
6
7 if (global[key] && global[key] !== process.env.BUILD_FORMAT) {
8 const initialBuildName = buildNames[global[key]];
9 const secondaryBuildName = buildNames[process.env.BUILD_FORMAT];
10
11 // TODO: Add link to article that explains in detail how to avoid
12 // loading 2 different builds.
13 throw new Error(
14 `You are loading the ${secondaryBuildName} build of React Router ` +
15 `on a page that is already running the ${initialBuildName} ` +
16 `build, so things won't work right.`
17 );
18 }
19
20 global[key] = process.env.BUILD_FORMAT;
21 }
22}
23
24export { default as MemoryRouter } from "./MemoryRouter.js";
25export { default as Prompt } from "./Prompt.js";
26export { default as Redirect } from "./Redirect.js";
27export { default as Route } from "./Route.js";
28export { default as Router } from "./Router.js";
29export { default as StaticRouter } from "./StaticRouter.js";
30export { default as Switch } from "./Switch.js";
31export { default as generatePath } from "./generatePath.js";
32export { default as matchPath } from "./matchPath.js";
33export { default as withRouter } from "./withRouter.js";
34
35import { useHistory, useLocation, useParams, useRouteMatch } from "./hooks.js";
36export { useHistory, useLocation, useParams, useRouteMatch };
37
38export { default as __HistoryContext } from "./HistoryContext.js";
39export { default as __RouterContext } from "./RouterContext.js";