-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
gatsby-link: add push (same as navigateTo) and replace methods #5934
Conversation
Deploy preview for using-drupal ready! Built with commit 8a8d892 |
Deploy preview for gatsbygram ready! Built with commit 8a8d892 |
Let's just add replace and push methods that do the same thing as |
Oh, guess we can keep this open as it'd be pretty easy to modify this PR :-) |
Should I then modify the documentation and examples to use |
Hmmm no, let's add it in v1 and document it there but make the change and deprecate it in v2 then remove Anyways, I can help you through that. |
OK, while I intend to also deal with v2, it looked today like it has not yet been merged, and so I have amended this v1 patch to have push and replace methods. Let me know if you want any changes. I'll soon get to v2. |
I've tweaked this version a little since my last comment, and I've also made a patch for v2 (PR referenced above). |
Fixed a broken test and replaced the commit. |
The errors in the CI build failure don't seem connected to this patch; they're about |
Oh, there's a lot of conflicts actually — could you resolve those? |
Are we adding this to v1? |
I can most likely do this later today.
That was the idea; see this earlier comment #5934 (comment) |
This addresses #5910
Rebased on the v1 branch. I'm not sure how to change the base of this pull request to v1... I can either close this and open a new PR, or you can manually merge with v1 your end:
|
Oh, in the rebase I lost your commit 999f1baa9 and I can't seem to fetch it from Github or follow the link to it above in this thread. Oops... |
Haha, but I can click the link to it from the comment I just posted. Github bug, methinks. Will add it... |
Added your readme change commit back on, and found the option to change the base for this PR. Should be ready to go. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @tremby!
I updated the readme example and added a small note about push
previously being named navigateTo
@m-allanson, I actually did have something like that but it was taken out in Kyle's commit: 8a8d892 Doesn't matter to me either way though! Thanks. |
...Did you mean to merge this into v1 but accidentally merge v1 into this instead? |
Ah sorry for the delay, GitHub wanted me to update the branch before merging. Merging now. |
This addresses #5910.
This patch adds a second argument to
gatsby-link
'snavigateTo
, which will accept an object. If the object has a truthyreplace
member,history.replace
is used rather thanhistory.push
. See the linked issue for my use case.Since following the history API's
replace
andpush
methods (as suggested in the issue by @KyleAMathews) would be a breaking change, perhaps this is a good solution in the mean time for the 1.x line?