Skip to content

Commit

Permalink
search params
Browse files Browse the repository at this point in the history
  • Loading branch information
Shiyu Wang committed Sep 22, 2023
1 parent bfe0a33 commit 09a96f2
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 deletions.
30 changes: 30 additions & 0 deletions src/components/SearchParams/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { useSearchParams } from 'react-router-dom';

const SearchParams = () => {
const [searchParams, setSearchParams] = useSearchParams({ title: '' });
const title = searchParams.get('title');
return (
<div>
<h1>Search Params</h1>
<div>
<label htmlFor='title'>Title</label>
<input
type='text'
id='title'
value={title}
onChange={(e) =>
setSearchParams(
(v) => {
v.set('title', e.target.value);
return v;
},
{ replace: true }
)
}
/>
</div>
</div>
);
};

export default SearchParams;
7 changes: 0 additions & 7 deletions src/components/SearchParams/index.tsx

This file was deleted.

0 comments on commit 09a96f2

Please sign in to comment.