In this chapter, we looked at how a React application can be rendered on the server-side (with Node.js and Express.js) using the ReactDOMserver.renderToString method. The <StaticRouter> component in React-Router can be used to wrap the application's root component, thus enabling you to add <Route> components that match the requested URL path on the server-side. The <StaticRouter> component accepts props context and location. The staticContext prop (available only on the server-side) in the rendered component contains the data provided by the <StaticRouter> in the context prop. It can also be used to add properties when you want to redirect the user using the <Redirect> component.
The matchPath function is used to determine whether the requested URL matches the provided object of the shape {path, exact, strict, sensitive}. It's similar...