I've looked through other answers and tried the solutions but I"m still getting a bit confused.
I've got a url, say www.sitename.com
and I've got a React app using react-router-dom
to do the routing.
<Router>
<Route
path={process.env.PUBLIC_URL + "/"}
exact={true}
component={Home}
/>
<Route path={process.env.PUBLIC_URL + "/about"} component={About} />
<Route
path={process.env.PUBLIC_URL + "/projects"}
component={Projects}
/>
<Route path={process.env.PUBLIC_URL + "/contact"} component={Contact} />
</Router>
I've imported HashRouter as Router in this project.
Other answers I've read say that this will solve the problem I was having of when a page is reloaded, the browser wouldn't be able to display anything as, for example, there was no content at www.sitename.com/about
as the rendering was controlled from the index.html
page.
Using the hash router did solve the problem, but now I can't direct people to www.sitename.com/about
as that page still doesn't exist, React seems to make the URL www.sitename.com/#/about
I've read the docs but can't seem to find an answer that makes sense to me!