Populate query box from url. Fixes #18.

This commit is contained in:
Dessalines 2018-11-29 16:59:03 -07:00
parent 27bb21d7c1
commit e774d4d8c3
1 changed files with 10 additions and 0 deletions

View File

@ -18,6 +18,7 @@ export class Navbar extends Component<any, State> {
constructor(props, context) { constructor(props, context) {
super(props, context); super(props, context);
this.fillSearchField();
} }
render() { render() {
@ -72,4 +73,13 @@ export class Navbar extends Component<any, State> {
} }
i.setState({ searchParams: searchParams }); i.setState({ searchParams: searchParams });
} }
fillSearchField() {
let splitPath: Array<string> = this.context.router.route.location.pathname.split("/");
if (splitPath.length == 4 && splitPath[1] == 'search')
this.state.searchParams = {
page: Number(splitPath[3]),
q: splitPath[2]
};
}
} }