reactpress icon indicating copy to clipboard operation
reactpress copied to clipboard

Document the requirement to attach the app to an element with the id "root"

Open BlairCooper opened this issue 11 months ago • 0 comments

ReactPress requires that the app load itself into an element with the id "root" as show below. Some frameworks follow this implementation detail while other do not.

const elem = document.getElementById('root');
ReactDOM.createRoot(elem);

One example, which happened to use Webpack as the framework, used the code below for loading the app. In this case main.js defines a component which gets loaded inline. This works fine and loads the app. However, dropping the app into ReactPress will not load the app as it does not attach to the element with the id "root".

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>Getting Started</title>
  </head>
  <body>
    <script src="main.js"></script>
  </body>
</html>

BlairCooper avatar Jan 29 '25 19:01 BlairCooper