More legacy shims related to the `/app` stuff.
parent
1a98629685
commit
ea13f16b0f
|
@ -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. */
|
||||
|
|
|
@ -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);
|
||||
}} />;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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));
|
||||
|
|
Loading…
Reference in New Issue