Skip to content

Instantly share code, notes, and snippets.

@akellbl4
Created June 9, 2021 06:12
Show Gist options
  • Save akellbl4/4ea12c02288d93db1905175818669c24 to your computer and use it in GitHub Desktop.
Save akellbl4/4ea12c02288d93db1905175818669c24 to your computer and use it in GitHub Desktop.
// 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