Skip to content

Commit c7ad69f

Browse files
committed
fix: fix playground
1 parent 9af49d4 commit c7ad69f

File tree

1 file changed

+6
-4
lines changed
  • website/src/components/playground

1 file changed

+6
-4
lines changed

website/src/components/playground/Query.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,18 @@ function formatQuery(state, initialState) {
1212
},
1313
{},
1414
)
15-
return qs.stringify(lightState, { arrayFormat: 'bracket' })
15+
const qsStr = qs.stringify(lightState, { arrayFormat: 'bracket' })
16+
return qsStr ? `?${qsStr}` : ''
1617
}
1718

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

2223
function getLocation() {
23-
if (typeof window === 'undefined') return { search: '', pathname: '' }
24-
return window.location
24+
if (typeof window === 'undefined')
25+
return { location: { search: '', pathname: '' } }
26+
return { location: window.location }
2527
}
2628

2729
let browserHistory
@@ -47,7 +49,7 @@ function useLocation() {
4749
export function useQuery(getInitialState = {}) {
4850
const history = useHistory()
4951
const [initialState] = React.useState(getInitialState)
50-
const location = useLocation()
52+
const { location } = useLocation()
5153
const locationRef = React.useRef(location)
5254
React.useEffect(() => {
5355
locationRef.current = location

0 commit comments

Comments
 (0)