Created
June 9, 2021 06:12
-
-
Save akellbl4/4ea12c02288d93db1905175818669c24 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// pages/params.jsx | |
import Router from 'next/router' | |
import { useRouter } from 'lib/router' | |
function MyComponent() { | |
const { query, pathname } = useRouter() | |
function handleSubmit(evt) { | |
const params = new FormData(evt.currentTarget).getAll("fruits"); | |
evt.preventDefault(); | |
Router.replace( | |
{ pathname, query: { ...query, params }}, | |
null, | |
{ shallow: true } | |
) | |
} | |
return ( | |
<form> | |
{...} | |
<button type="submit">Apply</button> | |
</form> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment