DEV Community

Discussion on: React Router with GitHub Pages

Collapse
 
zenulabidin profile image
Ali Sherief

About getting a 404 page running, I use

<Route
  render={props => <NotFoundPage {...props} />}
/>

in my BrowserRouter Switch with my own 404 page, instead of putting the homepage there.

Also you should consider passing the exact prop to your other paths so that /blog/invalidpath does not silently redirect to /blog. The 404 route shouldn't have the exact prop though.

Collapse
 
caffiendkitten profile image
DaNeil C

Thanks for the input. I have since changed it to a HashRouter for the GitHub Pages to get my refreshing to work and then the Switch with a 404 default pages works great. GitHub Pages is so picky.