From the course: Learning Full-Stack JavaScript Development: MongoDB, Node, and React
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Server-side rendering of the root path
From the course: Learning Full-Stack JavaScript Development: MongoDB, Node, and React
Server-side rendering of the root path
- [Instructor] The application is now rendering data from the API server with JavaScript. But what happens if we don't have JavaScript? We can actually disable JavaScript here in Chrome Dev tools down in the settings, there is a disable JavaScript option and if we test with JavaScript disabled the application is empty. The only thing that it renders is the original content that we rendered in the EJS template. This is what most search engines see if they request the application. Ideally, we want the application to render from the server as seen by React so that we get the benefits of search engine optimizations and also we get a little bit of performance benefit. Instead of waiting for React to warm up, render the component and then go back to the server to fetch the data, we can have an initial view ready by the server. So to do that let's go to server.ts and what we need is to modify this instead of a loading message,…
Contents
-
-
-
-
-
Creating a mock API endpoint5m 52s
-
(Locked)
Using an API endpoint from the browser9m 2s
-
(Locked)
Rendering a list of items8m 47s
-
(Locked)
React’s key for items in a list4m 29s
-
(Locked)
Fetching data while React is rendering8m 5s
-
(Locked)
Server-side rendering of the root path7m 41s
-
(Locked)
Sharing data between server and client5m 1s
-
(Locked)
Fetching data from MongoDB6m 17s
-
-
-