1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, '__esModule', { value: true });
|
4 |
|
5 | var React = require('react');
|
6 | var history = require('history');
|
7 | var reactRouterDom = require('react-router-dom');
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 | function StaticRouter({
|
14 | basename,
|
15 | children,
|
16 | location: locationProp = "/"
|
17 | }) {
|
18 | if (typeof locationProp === "string") {
|
19 | locationProp = history.parsePath(locationProp);
|
20 | }
|
21 |
|
22 | let action = history.Action.Pop;
|
23 | let location = {
|
24 | pathname: locationProp.pathname || "/",
|
25 | search: locationProp.search || "",
|
26 | hash: locationProp.hash || "",
|
27 | state: locationProp.state || null,
|
28 | key: locationProp.key || "default"
|
29 | };
|
30 | let staticNavigator = {
|
31 | createHref(to) {
|
32 | return typeof to === "string" ? to : history.createPath(to);
|
33 | },
|
34 |
|
35 | push(to) {
|
36 | throw new Error(`You cannot use navigator.push() on the server because it is a stateless ` + `environment. This error was probably triggered when you did a ` + `\`navigate(${JSON.stringify(to)})\` somewhere in your app.`);
|
37 | },
|
38 |
|
39 | replace(to) {
|
40 | throw new Error(`You cannot use navigator.replace() on the server because it is a stateless ` + `environment. This error was probably triggered when you did a ` + `\`navigate(${JSON.stringify(to)}, { replace: true })\` somewhere ` + `in your app.`);
|
41 | },
|
42 |
|
43 | go(delta) {
|
44 | throw new Error(`You cannot use navigator.go() on the server because it is a stateless ` + `environment. This error was probably triggered when you did a ` + `\`navigate(${delta})\` somewhere in your app.`);
|
45 | },
|
46 |
|
47 | back() {
|
48 | throw new Error(`You cannot use navigator.back() on the server because it is a stateless ` + `environment.`);
|
49 | },
|
50 |
|
51 | forward() {
|
52 | throw new Error(`You cannot use navigator.forward() on the server because it is a stateless ` + `environment.`);
|
53 | }
|
54 |
|
55 | };
|
56 | return React.createElement(reactRouterDom.Router, {
|
57 | basename: basename,
|
58 | children: children,
|
59 | location: location,
|
60 | navigationType: action,
|
61 | navigator: staticNavigator,
|
62 | static: true
|
63 | });
|
64 | }
|
65 |
|
66 | exports.StaticRouter = StaticRouter;
|