3

I'm trying to make an anchor tag which will link to a location within the same page (like this)

However React-Router hijacks that, and and routes me to nothing, as I haven't established that link in the hierarchy. So it sends me to the root location of that name, instead of a location on the same page.

ChadF
  • 1,750
  • 10
  • 22

1 Answers1

1

if i understand your question, you can use hashlocation instead of history location. like this

ReactRouter.run(routes, hashlocation, (Handler) => {
  React.render(<Handler/>);
});
Rei Dien
  • 196
  • 13
  • The router defaults to hashlocation and is already using that from root. I don't believe you can sub-hash a hashlocation. – ChadF Jul 29 '15 at 03:20
  • just create an ordinary link tag. tested and worked. also use historylocation. ` – Rei Dien Jul 29 '15 at 15:18
  • It seems Router.HistoryLocation only works when pairing with a server. I'm running a simple client-side app. – ChadF Jul 29 '15 at 18:18
  • i dont get what you mean. how are you suppose to run react router without a server? – Rei Dien Jul 31 '15 at 04:40
  • Related question in reference to your answer. Hoping you can help me clarify what different things are here. I'm using so I don't get how I can relate what I"m using to your answer....what is hashLocation vs. historyLocation? I think I'm using historyLocation which is browserHistory??? – PositiveGuy Jun 28 '16 at 05:15
  • @PositiveGuy this is an old version of the library. react-router moved away from using hash, but you can still use hashrouter, so historyLocation now has 2 types - browserHistory and memoryHistory. read more on the react-router-dom docs to know whats the difference. – Rei Dien Sep 19 '17 at 08:05