reactjs – React is giving me a major headache

So, I am in this front-end web development online course. The current term is teaching us how to code using React. I just started, so I am very new to this stuff. I installed the Node.js version on my computer, 22.4 I think is the version. The lessons are having me put in code to add a new h1 and p element to the page. I consulted Microsoft Copilot AI tool, where I learned that the ReactDOM.render function the lesson asks us to use actually became deprecated with React 18. Anyway, I copy and pasted the following code that the AI tool advised me to use, and I finally got no errors in the console, but nothing prints out on the webpage. I appreciate it if anyone has any ideas what is going on. Thank you much.

import React from 'react';
import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import App from './App';



const title = React.createElement('h1', null, 'My First React App');

const paragraph = React.createElement('p', null, 'I am creating React Nodes and      using the React library');

const rootElement = document.getElementById('root');
const root = createRoot(rootElement);
root.render([title, paragraph]);


root.render(
  
    
  
);

The code that the lesson asks us to use is the following, which obviously should print out the strings in the title and paragraph variables:

const title = React.createElement(‘h1’, null, ‘My First React App’);
const paragraph = React.createElement(‘p’, null, ‘I am creating React Nodes and using the React library’);

const container = React.createElement(‘div’, null, [title, paragraph]);

ReactDOM.render(
container,
document.getElementById(‘root’)

Read more here: Source link