On the server

"Now Shawn, let's pre-render the component on the server. What this means is that create an HTML element out of the React component and render its contents in our view on first page load itself. Currently, the loading of the element is taken care of by the client-side code."

app.renderToDOM(attachElement);

"Instead of this, we will render the React element in the Express action itself."

"First, let's set up an .ejs view to display out HTML contents along with dynamically-generated React contents."

<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title>Search</title> <link href="styles/main.css" rel="stylesheet" /> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"> <link ...

Get ReactJS by Example - Building Modern Web Applications with React now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.