index.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. if (__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. if (global[key] && global[key] !== process.env.BUILD_FORMAT) {
  7. const initialBuildName = buildNames[global[key]];
  8. const secondaryBuildName = buildNames[process.env.BUILD_FORMAT];
  9. // TODO: Add link to article that explains in detail how to avoid
  10. // loading 2 different builds.
  11. throw new Error(
  12. `You are loading the ${secondaryBuildName} build of React Router ` +
  13. `on a page that is already running the ${initialBuildName} ` +
  14. `build, so things won't work right.`
  15. );
  16. }
  17. global[key] = process.env.BUILD_FORMAT;
  18. }
  19. }
  20. export { default as MemoryRouter } from "./MemoryRouter.js";
  21. export { default as Prompt } from "./Prompt.js";
  22. export { default as Redirect } from "./Redirect.js";
  23. export { default as Route } from "./Route.js";
  24. export { default as Router } from "./Router.js";
  25. export { default as StaticRouter } from "./StaticRouter.js";
  26. export { default as Switch } from "./Switch.js";
  27. export { default as generatePath } from "./generatePath.js";
  28. export { default as matchPath } from "./matchPath.js";
  29. export { default as withRouter } from "./withRouter.js";
  30. export { default as __HistoryContext } from "./HistoryContext.js";
  31. export { default as __RouterContext } from "./RouterContext.js";
  32. export { useHistory, useLocation, useParams, useRouteMatch } from "./hooks.js";