Skip to content

Commit

Permalink
(WIP) Fix for routing
Browse files Browse the repository at this point in the history
  • Loading branch information
timothyis committed Apr 19, 2018
1 parent 045bd2c commit 6e05000
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
14 changes: 13 additions & 1 deletion components/Layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,16 @@ class Layout extends React.Component {

componentWillReceiveProps(nextProps) {
const { router } = nextProps
console.log(router.asPath)
if (!/^\/search/.exec(router.asPath)) {
this.setState({
searchQuery: null,
originalURL: router.asPath
})
} else {
this.setState({
originalURL: router.asPath
})
}
}

Expand Down Expand Up @@ -59,13 +64,20 @@ class Layout extends React.Component {
}

render() {
console.log(
this.state && this.state.searchQuery,
this.props.query,
this.props.router
)
return (
<div className="main">
<Meta />

<Header handleSearch={this.handleSearch} />

{(this.state && this.state.searchQuery) || this.props.query ? (
{(this.state && this.state.searchQuery) ||
this.props.query ||
this.props.router.query.q ? (
<SearchList
query={
this.state && this.state.searchQuery
Expand Down
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1132,8 +1132,8 @@ camelcase@^4.0.0, camelcase@^4.1.0:
resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-4.1.0.tgz#d545635be1e33c542649c69173e5de6acfae34dd"

caniuse-lite@^1.0.30000792:
version "1.0.30000820"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000820.tgz#6e36ee75187a2c83d26d6504a1af47cc580324d2"
version "1.0.30000830"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000830.tgz#cb96b8a2dd3cbfe04acea2af3c4e894249095328"

capture-stack-trace@^1.0.0:
version "1.0.0"
Expand Down

0 comments on commit 6e05000

Please sign in to comment.