Skip to content

Commit

Permalink
fix: fix playground
Browse files Browse the repository at this point in the history
  • Loading branch information
gregberge committed Jul 10, 2020
1 parent 9af49d4 commit c7ad69f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions website/src/components/playground/Query.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,18 @@ function formatQuery(state, initialState) {
},
{},
)
return qs.stringify(lightState, { arrayFormat: 'bracket' })
const qsStr = qs.stringify(lightState, { arrayFormat: 'bracket' })
return qsStr ? `?${qsStr}` : ''
}

function parseQuery(query) {
return qs.parse(query, { arrayFormat: 'bracket', parseBooleans: true })
}

function getLocation() {
if (typeof window === 'undefined') return { search: '', pathname: '' }
return window.location
if (typeof window === 'undefined')
return { location: { search: '', pathname: '' } }
return { location: window.location }
}

let browserHistory
Expand All @@ -47,7 +49,7 @@ function useLocation() {
export function useQuery(getInitialState = {}) {
const history = useHistory()
const [initialState] = React.useState(getInitialState)
const location = useLocation()
const { location } = useLocation()
const locationRef = React.useRef(location)
React.useEffect(() => {
locationRef.current = location
Expand Down

1 comment on commit c7ad69f

@vercel
Copy link

@vercel vercel bot commented on c7ad69f Jul 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.