Skip to content

docs(router): add pitfall when navigating for the useLocation hook #3371

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/router/framework/react/api/router/useLocationHook.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ title: useLocation hook

The `useLocation` method is a hook that returns the current [`location`](./ParsedLocationType.md) object. This hook is useful for when you want to perform some side effect whenever the current location changes.

> [!WARNING]
> When you are navigating to another route, this hook will be re-rendered with the next route's new `location` object because the current route's component does **not** unmount until the `pendingComponent` shows up.
>
> Be careful if you are using some values from the `location` object to perform side effects or render conditional UI.

## useLocation options

The `useLocation` hook accepts an optional `options` object.
Expand Down