/, Javascript, Learning, React, Web Development/Something I wish I knew 7 days ago…

Something I wish I knew 7 days ago…

Before I began migrating my Express with Pug (the template/view engine) to a server side rendered React app, I wish somebody told me this one thing:

“For anything that is going to show HTML, you are always going to make sure that React Router is in charge of making that request”

This one line of spoken word would have saved me in excess of 20 hours.

I do not regret those 20 hours that I did spend trying to essentially integrate React with Pug and somehow render React server side. Those hours were, in fact, well spent. But I was deep down a rabbit hole. It wasn’t until my mentor blocked javascript in the browser and tested my application to see if it still rendered that I fell into that hole!

Anyway, now I’m learning how to do things properly by watching this course. The main takeaway here is that you cannot server side render react components based on Express routing. It just doesn’t work. Express routes need to explicitly cover one-off routes that cover routing logic such as outside requests, API handlers, or handlers that return JSON. The rest, as they say, is React.

 

By |2018-08-15T22:11:28+00:00August 15th, 2018|Express, Javascript, Learning, React, Web Development|0 Comments

About the Author:

Leave A Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.