Skip to content

Commit

Permalink
fix: replace search query with hash
Browse files Browse the repository at this point in the history
  • Loading branch information
easy-death committed Oct 25, 2022
1 parent 4cbf846 commit 27ab2c9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function saveHistory({query, page, gifs}: HistoryState){
const params = new URLSearchParams();
if (query !== '') params.append('query', query);
if (page !== 1) params.append('page', page.toString());
window.history.pushState({query, page, gifs} as HistoryState, '', "/?" + params.toString());
window.history.pushState({query, page, gifs} as HistoryState, '', "/#" + params.toString());
}


Expand Down Expand Up @@ -96,7 +96,7 @@ function App() {
});
// restore local vars from url
useEffectOnce(() => {
const params = new URLSearchParams(window.location.search);
const params = new URLSearchParams(window.location.hash.slice(1));
const q = params.get('query') ?? '';
const p = parseInt(params.get('page') ?? '1');
setInputText(q);
Expand Down

0 comments on commit 27ab2c9

Please sign in to comment.