In my app, I\'d like to match both the path and the hash to different components. For example:
/pageA#modalB
Would show PageA as the main page
@azium answer works fine as long as you don't need to use render or children prop in HashRoute. In which case this solution will work better :
import React from 'react';
import { Route } from 'react-router-dom';
const HashRoute = ({ hash, ...routeProps }) => (
(
(location.hash === hash) &&
)}
/>
);
export default HashRoute;
Use it like that :
Or combine it with route matching :