Skip to content

Commit

Permalink
Sync search box value with URL query on first render
Browse files Browse the repository at this point in the history
  • Loading branch information
DukeManh committed Feb 13, 2021
1 parent 407d57d commit f66f7d7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/frontend/next/src/components/SearchPage.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FormEvent, useState } from 'react';
import { FormEvent, useState, useEffect } from 'react';
import { makeStyles } from '@material-ui/core/styles';
import { useRouter } from 'next/router';

Expand Down Expand Up @@ -39,6 +39,11 @@ const SearchPage = () => {
router.push(`/search?text=${text}&filter=${filter}`);
}

useEffect(() => {
setText(textParam);
setFilter(filterParam);
}, [textParam, filterParam]);

return (
<div>
<div className={classes.anchor} id="back-to-top-anchor" />
Expand Down

0 comments on commit f66f7d7

Please sign in to comment.