question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ability to unsubscribe from hashHistory.listen()

See original GitHub issue

While trying to find the best solution for creating my own breadcrumb, I found it difficult to get route information into a sibling component in my case a navigation bar.

As of right now i’m using the hashHistory.listen() method and splitting the response using event.pathname.split("/"). This method works but since i’m using an event listener i receive an error if i navigate to a new route that doesn’t contain my component. This the the expected behavior which leads me to think that there should be an unlisten() method to hashHistory.

Another plus would be to have both parent and child routes listed in the hashHistory.listen() response. This would help tremendously in know the exact components used to render parameters.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
timdorrcommented, Sep 7, 2016

First, the return from history.listen() is an “unlisten” function you can call.

But you’re provided the location on your route component. Pass that down via props to your breadcrumb component if you need it deeper in the tree.

0reactions
edgeadjeicommented, Sep 13, 2016

After further research i finally understand what you were both trying to convey. I couldn’t wrap my mind around how a parent component would know a child component’s route without re-rendering. but for anybody looking to accomplish the same task you can get all active routes in a child component by passing routes={this.props.routes} to the component and access the current route object using routes[routes.length -1]

Thank you both. React router is awesome.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ability to unsubscribe from hashHistory.listen() #3792 - GitHub
listen() is an "unlisten" function you can call. But you're provided the location on your route component. Pass that down via props to...
Read more >
Prevent react-router history.push from reloading current route
I'm taking my first steps with react-router . I'm currently using the hashHistory for development purposes and I'm performing 'manual' navigation. That is...
Read more >
Different History modes - Vue Router
The hash history mode is created with createWebHashHistory() : ... but note there will be no history, meaning you won't be able to...
Read more >
Lock API Reference - Auth0
Lock has many methods, features, and configurable options. This reference is designed to direct you to the ones that you need, and discuss...
Read more >
历史 | React 和 Webpack 小书
React Router is built on history. In a nutshell, a history knows how to listen to the browser's address bar for changes and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found