r/reactjs • u/timmonsjg • Oct 02 '18
Needs Help Beginner's Thread / Easy Questions (October 2018)
Hello all!
October marches in a new month and a new Beginner's thread - September and August here. Summer went by so quick :(
Got questions about React or anything else in its ecosystem? Stuck making progress on your app? Ask away! We’re a friendly bunch. No question is too simple. You are guaranteed a response here!
Want Help with your Code?
- Improve your chances by putting a minimal example to either JSFiddle or Code Sandbox. Describe what you want it to do, and things you've tried. Don't just post big blocks of code!
- Pay it forward! Answer questions even if there is already an answer - multiple perspectives can be very helpful to beginners. Also there's no quicker way to learn than being wrong on the Internet.
New to React?
Here are great, free resources!
23
Upvotes
View all comments
Show parent comment
1
u/jamesknelson Oct 13 '18
Now that you mention it, that is a kind of confusing name.
So when you do a build with CRA, it only outputs a single HTML file: index.html.
If your app uses the browser's
pushStateAPI (or a router that uses it like react-router), then it can still be made to "navigate" to other pages (i.e. change the address in the URL bar). But if you then refresh the page, you won't be at the originalindex.htmlfile, so you'll get a 404.There's two ways to fix this: one is to configure the webserver to serve your index.html as a 404 page, so the app will always load. Another is to build separate html files for each of the page's URLs, i.e. statically build the site.