Skip to content

Add back functionality to navigate route#197

Merged
ryanflorence merged 1 commit into
reach:masterfrom
stasiukanya:navigate-back
Sep 5, 2019
Merged

Add back functionality to navigate route#197
ryanflorence merged 1 commit into
reach:masterfrom
stasiukanya:navigate-back

Conversation

@stasiukanya

Copy link
Copy Markdown

Implements #44

Uses history.go as suggested by @ryanflorence in #44 (comment)

@enzoferey

Copy link
Copy Markdown

Any chances this gets merged ? I think this is pretty useful for Gatsby as the window object can't be used during build process.

Related to this issue.

@brion-fuller

Copy link
Copy Markdown

Any update for this PR?

@peterlaxalt

Copy link
Copy Markdown

Would love to see this get merged. 🤘

@icyJoseph

Copy link
Copy Markdown

Does this implementation re-render the previous tree? #44 (comment)

@erasmuswill

Copy link
Copy Markdown

This would be great!

@bpurtz

bpurtz commented Jul 31, 2019

Copy link
Copy Markdown

+1

@calpa

calpa commented Aug 2, 2019

Copy link
Copy Markdown

Why not merge this commit?

@revskill10

Copy link
Copy Markdown

+1000000

@crutchcorn

Copy link
Copy Markdown

Please refrain from adding +1 comments. Adding emoji reacts communicates the same enthusiasm for the work without cluttering the thread

@tanigaki39

Copy link
Copy Markdown

+1

@erasmuswill

Copy link
Copy Markdown

+100

@blake-hunsicker

Copy link
Copy Markdown

+1000

@lesmo

lesmo commented Aug 19, 2019

Copy link
Copy Markdown

I believe that the createMemorySource should also implement this expected behavior on the history::go method. It's currently undefined.

@erasmuswill

Copy link
Copy Markdown

+10000

@Kadrian

Kadrian commented Sep 2, 2019

Copy link
Copy Markdown

Coming from Gatsby as well, wondering why it's still not possible to simply .goBack().

So, what's missing for this PR to get merged?

Feedback from @ryanflorence ? Clicking "merge" by @stasiukanya?

@ryanflorence

Copy link
Copy Markdown
Member

Thanks for your patience.

My hesitation here has been around how suspense and caches are going to work.

If you click "back" do we need to go into the transitioning state or can we assume since we're going somewhere we've already visited the cache will be filled already?

This PR assumes the cache will be filled. And I suppose the code already assumes they will be filled if the user clicks back.

Anyway, we may find issues when suspense ships in 2032, and we can figure out what to do then.

(j/k react team I love you suspense is going to be amazing)

@ryanflorence ryanflorence merged commit 697cee0 into reach:master Sep 5, 2019
@stasiukanya stasiukanya deleted the navigate-back branch September 5, 2019 08:42
@LouiseReid

Copy link
Copy Markdown

Should this now be working as its merged to master? I'm using v1.2.1 and passing an int to navigate just attaches it to the end of the url

@ZeeEssDoubleU

ZeeEssDoubleU commented Oct 9, 2019

Copy link
Copy Markdown

I'm having the same issue.

navigate(-1) just appends '-1' to the end of the url

@erasmuswill

Copy link
Copy Markdown

When this works I have some production workarounds to rectify xD

@ricksmit3000

ricksmit3000 commented Oct 26, 2019

Copy link
Copy Markdown

this doesn't quite work yet with in the beta release: to === "/-1" so it doesn't pass the typeof to === "number" check. somewhere it prepends to with a slash.
sorry issue was actually in gatsby-link

@mckelveygreg

Copy link
Copy Markdown

I'm also on 1.2.1 and it is just appending a -1.

@ricksmit3000

Copy link
Copy Markdown

Yeah so the fix is on the beta release, so just do ‘yarn add @reach/router@next’

@luistak

luistak commented Feb 15, 2020

Copy link
Copy Markdown

In some use cases I suggest:

<Link to="../">Back</Link>

@adamthrottleup

adamthrottleup commented Aug 3, 2020

Copy link
Copy Markdown

I am also seeing the issue where navigate(-1) is appending a -1 to the url.

I ran ‘yarn add @reach/router@next’ as suggested by @rickiesmooth but the issues persists. Any fix for this yet?

This is my implementation in Gatsby

import { navigate } from "@reach/router";

const goBack = () => {
navigate(-1);
}

<a onClick={goBack} className="back-link">Back</a>

@adamthrottleup

Copy link
Copy Markdown

I am also seeing the issue where navigate(-1) is appending a -1 to the url.

I ran ‘yarn add @reach/router@next’ as suggested by @rickiesmooth but the issues persists. Any fix for this yet?

This is my implementation in Gatsby

import { navigate } from "@reach/router";

const goBack = () => {
navigate(-1);
}

<a onClick={goBack} className="back-link">Back</a>

FYI I fixed this by updating my project's packages to the latest versions by running
yarn upgrade

I'm assuming this worked because I got the latest fix to gatsby mentioned above (gatsby was updated to v2.24.63)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.