Skip to content

provided HashRouter with own createHref implementation #4024

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

Merged
merged 4 commits into from
Oct 13, 2016
Merged

provided HashRouter with own createHref implementation #4024

merged 4 commits into from
Oct 13, 2016

Conversation

herrkris
Copy link
Contributor

I added an extra function since the link looks different when using hashType hashbang.

This is a fix for #4022. I hope I'm doing it the right way, since this is more or less my first PR.
Help appreciated, especially if it needs tests :)

Copy link
Member

@timdorr timdorr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add some tests? Thanks!

@ryanflorence
Copy link
Member

Can't we just send along the prop given to HashRouter to HashHistory? I'm probably missing something, I haven't looked at the hash stuff recently.

@alisd23
Copy link
Contributor

alisd23 commented Oct 11, 2016

The issue here is not the url which is pushed to history, that works fine. It's the href on the Link component's a element - https://github.com/ReactTraining/react-router/blob/v4/modules/Link.js#L98.

It fixes browser behaviour such as right-click -> open in new tab, which before would take you to the wrong url.

@timdorr
Copy link
Member

timdorr commented Oct 11, 2016

LGTM. Thanks for the tests!

@ryanflorence
Copy link
Member

https://github.com/ReactTraining/react-history/blob/master/modules/HashHistory.js#L19-L21

Looks like we need cases for hashbang, noslash, and slash.

Copy link
Contributor

@alisd23 alisd23 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Provide cases for hashbang, noslash, and slash

@herrkris
Copy link
Contributor Author

I imported two functions from the history/PathUtils : stripLeadingSlash and addLeadingSlash.

I don't know if this is the best solution since the LocationUtils.js imports two functions from react-history/PathUtils which itself just exports parsePath and createPath from history/PathUtils.

Perhaps we can also add the two methods to react-history/PathUtils export?

I hope that makes sense somehow ...

@alisd23
Copy link
Contributor

alisd23 commented Oct 12, 2016

I think what you did makes sense, we know history is always going to be a dependency. Looks good to me now 👍

@ryanflorence
Copy link
Member

history is fine, I'm actually killing react-history this week.

@ryanflorence ryanflorence merged commit 094fcda into remix-run:v4 Oct 13, 2016
@ryanflorence
Copy link
Member

Thanks @herrkris 🏆

@lock lock bot locked as resolved and limited conversation to collaborators Jan 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants