Skip to content

Commit

Permalink
docs(gatsby-link): Added some information regarding the limitations w…
Browse files Browse the repository at this point in the history
…ith the link package (#11909)

## Description

The `<Link>` component and the `navigate` function do not allow the user to replace to a hash-link nor a query parameter while `@reach/router` allows it. This PR adds a small section in the Link API docs to let users know of possible workarounds this limitation.

This was discussed in this PR: #11625
  • Loading branch information
Guillaume St-Pierre authored and DSchau committed Feb 26, 2019
1 parent c33fcfd commit 66f6db0
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions docs/docs/gatsby-link.md
Original file line number Diff line number Diff line change
Expand Up @@ -356,3 +356,19 @@ You can similarly check for file downloads:
```
[egghead]: https://egghead.io/playlists/use-gatsby-s-link-component-to-improve-site-performance-and-simplify-site-development-7ed3ddfe
## Recommendations for programmatic, in-app navigation
Neither `<Link>` nor `navigate` can be used for in-route navigation with a hash or query parameter. If you need this behavior, you should either use an anchor tag or import the `@reach/router` package--which Gatsby already depends upon--to make use of its `navigate` function, like so:
```jsx
import { navigate } from '@reach/router';
...
onClick = () => {
navigate('#some-link');
// OR
navigate('?foo=bar');
}
```

0 comments on commit 66f6db0

Please sign in to comment.