Question about the root node

Hello everyone :slight_smile: i am doing the React courses and i am wondering in a case of a real app where to put the root node (since the one used in the challenges is autogenerated behind the scene)

Hi @NizarMhirsi !

Welcome to the forum!

You would create an index.js file and render your App component there.

If you use create react app these files will be automatically generated for you.

Here is an example of what the index.js file would look like.

import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';

ReactDOM.render(
  <React.StrictMode>
    <App />
  </React.StrictMode>,
  document.getElementById('root')
);

Hope that helps!

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.