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.

How to hide Parent when child route is active

See original GitHub issue

Hi,

I tried to implement React Router example. Here’s the codesandbox link.

Screenshot-2019-01-24-at-12-58-34-PM.png

The links at top is the breadcrumb

The links to Bus and Cart at bottom is present on the parent route Tacos but is visible on child route Bus or Cart

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
pjvdscommented, Jul 21, 2019

Thanks @icd2k3 for the fast and prompt answer ❤️

0reactions
icd2k3commented, Jul 19, 2019

@pjvds it’s a bit verbose, but since location is passed to dynamic breadcrumbs, we can use that to determine wether or not to show “Tacos”

const routes = [
  {
    path: "/tacos",
    breadcrumb: ({ location: { pathname } }) =>
      pathname.toLowerCase() === "/tacos" ? "Tacos" : null
  },
];

Here’s a codesandbox

gif

Read more comments on GitHub >

github_iconTop Results From Across the Web

Hide parent view in angular 2 - Stack Overflow
Make separate component for the one you called parent (ParentComponent) and for the one you called child (ChildComponent) ...
Read more >
Hide parent component but show child-angular.js
No way to do it, that's just a part of how parent and child component relationship works. The parent contains the child component,...
Read more >
How to hide parent route, when navigating to child route?
In react-router it is history.push(path, state) then you can read the stat from location . There is useHistory hook, and I guess there...
Read more >
How to navigate to a parent route from a child route?
Directly using the routerLink directive in case of linkage of child to parent. Using Route class in case of navigation to happen on...
Read more >
Angular Router: Children or LoadChildren?
Make sure you import all NgModules for each component defined in the nested route table. Otherwise, your code would not work. To help...
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