GeezerVison is showing github.com — fix: fix playground · gregberge/svgr@c7ad69f
File tree
Expand file treeCollapse file tree
Open diff view settings
website/src/components/playground
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: website/src/components/playground/Query.js +6-4Lines changed: 6 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -12,16 +12,18 @@ function formatQuery(state, initialState) { |
12 | 12 | }, |
13 | 13 | {}, |
14 | 14 | ) |
15 | | - return qs.stringify(lightState, { arrayFormat: 'bracket' }) |
| 15 | + const qsStr = qs.stringify(lightState, { arrayFormat: 'bracket' }) |
| 16 | + return qsStr ? `?${qsStr}` : '' |
16 | 17 | } |
17 | 18 |
|
18 | 19 | function parseQuery(query) { |
19 | 20 | return qs.parse(query, { arrayFormat: 'bracket', parseBooleans: true }) |
20 | 21 | } |
21 | 22 |
|
22 | 23 | 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 } |
25 | 27 | } |
26 | 28 |
|
27 | 29 | let browserHistory |
@@ -47,7 +49,7 @@ function useLocation() { |
47 | 49 | export function useQuery(getInitialState = {}) { |
48 | 50 | const history = useHistory() |
49 | 51 | const [initialState] = React.useState(getInitialState) |
50 | | - const location = useLocation() |
| 52 | + const { location } = useLocation() |
51 | 53 | const locationRef = React.useRef(location) |
52 | 54 | React.useEffect(() => { |
53 | 55 | locationRef.current = location |
|