Should I render all my HTML with React JSX or keep the static HTML in my .html file, and why?

  html, javascript, react-dom, reactjs, rendering

For a page that has mostly static HTML and a few dynamically rendered elements, is it best practice to render all HTML through React, or to leave the static HTML in an HTML file and only render targeted elements as needed with React?


Here’s what I’m considering for the why, feedback welcome:

  • All HTML in React: because this ensures all HTML is coming from one centralized location and is easier to understand
  • Only dynamic HTML in React, because:
    1. A plain html file is most likely to render the DOM successfully, so even if the React app scripts have an issue you’ll still render the rest of the page
    2. From an efficiency perspective, is an HTML file faster to load than React rendering?

I know this is similar to this question, but the one answer didn’t really address the "why". How much static HTML should I serve with React?

Source: Ask Javascript Questions

LEAVE A COMMENT