UNPKG

1.51 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";
25export { default as Prompt } from "./Prompt";
26export { default as Redirect } from "./Redirect";
27export { default as Route } from "./Route";
28export { default as Router } from "./Router";
29export { default as StaticRouter } from "./StaticRouter";
30export { default as Switch } from "./Switch";
31export { default as generatePath } from "./generatePath";
32export { default as matchPath } from "./matchPath";
33export { default as withRouter } from "./withRouter";
34
35import { useHistory, useLocation, useParams, useRouteMatch } from "./hooks.js";
36export { useHistory, useLocation, useParams, useRouteMatch };
37
38export { default as __RouterContext } from "./RouterContext";