Skip to content

Commit

Permalink
Persist query string when navigating (#8683)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ibrahim committed Feb 25, 2022
1 parent 59b319f commit 8601f27
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions contributors.yml
Expand Up @@ -13,6 +13,7 @@
- hongji00
- hsbtr
- hyesungoh
- IbraRouisDev
- JakubDrozd
- jmargeta
- jonkoops
Expand Down
5 changes: 4 additions & 1 deletion docs/getting-started/tutorial.md
Expand Up @@ -812,6 +812,7 @@ import { getInvoice, deleteInvoice } from "../data";
export default function Invoice() {
let navigate = useNavigate();
let location = useLocation();
let params = useParams();
let invoice = getInvoice(parseInt(params.invoiceId, 10));
Expand All @@ -826,7 +827,7 @@ export default function Invoice() {
<button
onClick={() => {
deleteInvoice(invoice.number);
navigate("/invoices");
navigate("/invoices" + location.search);
}}
>
Delete
Expand All @@ -837,6 +838,8 @@ export default function Invoice() {
}
```

Notice we used `useLocation` again to persist the query string by adding `location.search` to the navigation link.

## Getting Help

Congrats! You're all done with this tutorial. We hope it helped you get your bearings with React Router.
Expand Down

0 comments on commit 8601f27

Please sign in to comment.