Rendering components
suggest changeThere are two options for rendering components on the server: renderToString and renderToStaticMarkup.
renderToString
This renders React components to HTML on the server. In React 15 it also adds data-reactid markers so client React can hydrate the markup instead of creating those elements again.
import { renderToString } from "react-dom/server";
renderToString(<App />);
renderToStaticMarkup
This renders React components to HTML without the React 15 hydration markers. Do not use it for markup that client React will hydrate, because the client cannot reuse that HTML and will render the tree again.
import { renderToStaticMarkup } from "react-dom/server";
renderToStaticMarkup(<App />);
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents