Languages
[Edit]
EN

React / react-router - route respond to multiple paths

0 points
Created by:
Dirask JS Member
3610

In this article, we would like to show you how to set Route to respond to more than one paths in react-router.   

Quick solution: 

<Route path="/(path1|path2)/" component={component} />

Practical example:

import { Route } from 'react-router-dom';

const App = () => {
    // Some code...
    
    <Route path='/(home|faq)/' component={Home} />;
};

Home component is rendered for the '/home' and '/faq' paths.

React - react-router

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join