I am using the same component for three different routes:
<Router>
<Route path="/home" component={Home} />
<Route path="/users" component={Home} />
<Route path="/widgets" component={Home} />
</Router>
Is there anyway to combine it, to be like:
<Router>
<Route path=["/home", "/users", "/widgets"] component={Home} />
</Router>
As of react-router v4.4.0-beta.4, and officially in v5.0.0, you can now specify an array of paths which resolve to a component e.g.
<Router>
<Route path={["/home", "/users", "/widgets"]} component={Home} />
</Router>
Each path in the array is a regular expression string.
The documentation for this approach can be found here.