More legacy shims related to the `/app` stuff.

pull/991/head
Rick Carlino 2018-09-14 15:00:15 -05:00
parent 1a98629685
commit ea13f16b0f
4 changed files with 15 additions and 5 deletions

View File

@ -1,6 +1,9 @@
import { navigate } from "takeme";
import { maybeStripLegacyUrl } from "./link";
export const push = (url: string) => navigate(url);
export const push = (url: string) => {
navigate(maybeStripLegacyUrl(url));
};
export const getPathArray = () => location.pathname.split("/");
/** This is a stub from the `react-router`. Don't use it anymore. */

View File

@ -8,6 +8,9 @@ interface LinkProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> {
className?: string;
}
export const maybeStripLegacyUrl =
(url: string) => url.startsWith("/app") ? url.replace("/app", "") : url;
export const Link: React.SFC<LinkProps> = (props) => <a
{...props}
href={props.to}
@ -15,6 +18,6 @@ export const Link: React.SFC<LinkProps> = (props) => <a
e.preventDefault();
/** BEGIN LEGACY SHIMS */
const { onClick, to } = props;
navigate(to.startsWith("/app") ? to.replace("/app", "") : to);
navigate(maybeStripLegacyUrl(to));
onClick && onClick(e);
}} />;

View File

@ -41,8 +41,7 @@ function drt<T>(i: SpecialRoute<T>) {
const El: any = (await getChild())[key];
const { FarmDesigner } = await import("./farm_designer");
const stub: any = {
children: <El />,
key: "FARM_DESIGNER_DYNAMIC_MAGIC"
children: <El />
};
callback(() => <FarmDesigner {...stub} />, info);
} catch (e) {

View File

@ -36,7 +36,12 @@ export class RootComponent extends React.Component<RootComponentProps, RootCompo
}
changeRoute =
(c: React.ComponentType) => this.setState({ CurrentRoute: c });
(c: React.ComponentType) => {
console.group();
console.count("changeRoute");
this.setState({ CurrentRoute: c });
console.groupEnd();
}
componentDidMount() {
const routes = UNBOUND_ROUTES.map(bindTo => bindTo(this.changeRoute));