Top Interview questions on React Router DOM and routing in React
- Explain the purpose of React Router DOM.
- How would you set up routing for a simple app with 'Home', 'About', and 'Contact' pages?
- How can you handle a 404 page or fallback route in React Router?
- What is the difference between BrowserRouter and HashRouter?
- How would you implement nested routes in a React app?
- How can you pass data or parameters through routes in React Router?
- What is the useNavigate hook, and when would you use it over <Link>?
- Explain the difference between Route and Routes in React Router DOM v6.
- How would you implement protected or private routes?
- Describe how to handle programmatic redirects in React Router DOM.