Skip to Content
Full-Stack React Projects - Second Edition
book

Full-Stack React Projects - Second Edition

by Shama Hoque
April 2020
Intermediate to advanced
716 pages
18h 55m
English
Packt Publishing
Content preview from Full-Stack React Projects - Second Edition

Modules for server-side rendering

To implement basic server-side rendering, we will need to import the following React, React Router, and Material-UI-specific modules into the server code. In our code structure, the following modules will be imported into server/express.js:

  • React modules: The following modules are required to render the React components and use renderToString:
import React from 'react'import ReactDOMServer from 'react-dom/server'
  • Router modules: StaticRouter is a stateless router that takes the requested URL to match with the frontend route which was declared in the MainRouter component. The MainRouter is the root component in our frontend.

import StaticRouter from 'react-router-dom/StaticRouter'import MainRouter from ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Full-Stack React Projects

Full-Stack React Projects

Shama Hoque
React Native - The Practical Guide

React Native - The Practical Guide

Academind by Maximilian Schwarzmüller GmbH

Publisher Resources

ISBN: 9781839215414Supplemental Content