@reach/router: fix Location props

This commit is contained in:
kingdaro 2018-06-05 17:24:45 -04:00
parent ed64b074de
commit 03eb09d3c3
2 changed files with 17 additions and 2 deletions

View File

@ -92,7 +92,11 @@ export interface NavigateOptions<TState> {
replace?: boolean;
}
export class Location extends React.Component<LocationContext> {}
export interface LocationProps {
children: LocationProviderRenderFn;
}
export class Location extends React.Component<LocationProps> {}
export interface LocationProviderProps {
history: History;

View File

@ -1,4 +1,4 @@
import { Link, RouteComponentProps, Router } from "@reach/router";
import { Link, Location, RouteComponentProps, Router } from "@reach/router";
import * as React from "react";
import { render } from "react-dom";
@ -21,6 +21,17 @@ render(
<NotFound default />
<Link to="/somepath" rel="noopener noreferrer" target="_blank" />
<Location>
{(context) => (
<>
<div>hostname is {context.location.hostname}</div>
<button onClick={() => context.navigate("/")}>
Go Home
</button>
</>
)}
</Location>
</Router>,
document.getElementById("app-root"),
);