Skip to content

Commit 6e05000

Browse files
committed
(WIP) Fix for routing
1 parent 045bd2c commit 6e05000

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

components/Layout.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,16 @@ class Layout extends React.Component {
2323

2424
componentWillReceiveProps(nextProps) {
2525
const { router } = nextProps
26+
console.log(router.asPath)
2627
if (!/^\/search/.exec(router.asPath)) {
2728
this.setState({
2829
searchQuery: null,
2930
originalURL: router.asPath
3031
})
32+
} else {
33+
this.setState({
34+
originalURL: router.asPath
35+
})
3136
}
3237
}
3338

@@ -59,13 +64,20 @@ class Layout extends React.Component {
5964
}
6065

6166
render() {
67+
console.log(
68+
this.state && this.state.searchQuery,
69+
this.props.query,
70+
this.props.router
71+
)
6272
return (
6373
<div className="main">
6474
<Meta />
6575

6676
<Header handleSearch={this.handleSearch} />
6777

68-
{(this.state && this.state.searchQuery) || this.props.query ? (
78+
{(this.state && this.state.searchQuery) ||
79+
this.props.query ||
80+
this.props.router.query.q ? (
6981
<SearchList
7082
query={
7183
this.state && this.state.searchQuery

yarn.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,8 +1132,8 @@ camelcase@^4.0.0, camelcase@^4.1.0:
11321132
resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-4.1.0.tgz#d545635be1e33c542649c69173e5de6acfae34dd"
11331133

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

11381138
capture-stack-trace@^1.0.0:
11391139
version "1.0.0"

0 commit comments

Comments
 (0)