Skip to content

Commit

Permalink
fix: add a window ward
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Jun 11, 2019
1 parent 8711e1a commit 164ba4b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/components/hook/use-query-state.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ import { navigate } from 'gatsby'

export const useQueryState = () => {
const [urlSearchParams, setUrlSearchParams] = useState(new URLSearchParams())
useEffect(() => {
setUrlSearchParams(new URLSearchParams(window.location.search))
}, [window.location.search])
useEffect(
() => {
setUrlSearchParams(new URLSearchParams(window.location.search))
},
window ? [window.location.search] : []
)

const query = fromEntries(urlSearchParams.entries())

Expand Down

0 comments on commit 164ba4b

Please sign in to comment.