EN
React / react-router - route respond to multiple paths
0 points
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:
xxxxxxxxxx
1
<Route path="/(path1|path2)/" component={component} />
Practical example:
xxxxxxxxxx
1
import { Route } from 'react-router-dom';
2
3
const App = () => {
4
// Some code...
5
6
<Route path='/(home|faq)/' component={Home} />;
7
};
Home component is rendered for the '/home' and '/faq' paths.