07 / 14

How to link to routes from components?

Difficulty: 4/10
react-router, programmatic navigation, link component
javascript

Scenario Questions

0-2 years experience

  1. 1You have a component that renders a list of products. How would you make each product name navigate to its detail page when clicked?
  2. 2If you use the <Link> component but forget to wrap your app with a router, what error will you see and why?

2-5 years experience

  1. 1We need to add a 'Back' button that returns the user to the previous page, but sometimes the user lands directly on the page via an external link. How would you implement this navigation safely?
  2. 2During a recent release, clicking a navigation link caused the page to reload instead of using client‑side routing. What could cause that and how would you debug it?

5-8 years experience

  1. 1Our application has a deep nested route hierarchy and we want to generate links dynamically based on the current location. How would you build a utility that creates correct relative links and avoids broken URLs when the route structure changes?
  2. 2We are seeing performance regressions because many components render <Link> with heavy inline functions. What strategies would you use to minimize re‑renders while keeping navigation declarative?

8+ years experience

  1. 1We are migrating a legacy monolith to a micro‑frontend architecture, each team owns its own route subtree. How would you design a shared routing layer that allows teams to add links without tightly coupling to each other's code?
  2. 2Our SEO team wants server‑side rendered routes but also needs client‑side navigation for a seamless SPA experience. What architectural patterns would you adopt to reconcile SSR link generation with client navigation, and what trade‑offs are involved?

Follow-up Questions

  • What would you do if you needed to pass data to the target route without putting it in the URL?
  • How does React Router prevent a full page reload when using <Link>?
  • Can you describe a scenario where you’d prefer navigate over <Link>?
Share

Share via WhatsApp, X, Facebook, LinkedIn or copy link. Open Graph preview enabled.