https://github.com/devinekask/react-router-demo https://devinekask.github.io/react-router-demo/
- State lives in the
App.jsx
- The Routes are defined in
App.jsx
, not inmain.jsx.
- Doing so, all the routes can access the state variables.
- In
main.jsx
We make use of aHashRouter
instead of the defaultBrowserRouter
- This is because of the way GitHub Pages handles requests. When one would refresh a route like
/edit/
or so, GitHub Pages expects a 'edit' file or directory. Since we're creating a SPA, there is only anindex.html
. There is no way to configure GitHub Pages to redirect everything to theindex.html
. When using aHashRouter
, a#
is prepended to the route, so every request is passed to theindex.html
file.
- This is because of the way GitHub Pages handles requests. When one would refresh a route like