Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

React Not Displaying / Rendering

I recently started learning React. I wanted to make my first app and have done the following.

  1. Created a project folder
  2. Ran npx create-react-app App.js
  3. Ran npm start

My src/App.js is as follows:

import React from "react";
import ReactDOM from "react-dom/client";

const navbar = (
    <nav>
        <h1>Wiggly's</h1>
        <ul>
            <li>Menu</li>
            <li>About</li>
            <li>Contact</li>
        </ul>
    </nav>
);

const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(navbar);

My index.html is as follows:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>HTML 5 Boilerplate</title>
    <link rel="stylesheet" href="">
</head>

<body>
    <div id="root">

    </div>

    <script src="App.js"></script>
</body>


</html>

When I refresh my localhost I still see the react splash screen.

I’ve looked everywhere on the forums and haven’t been able to figure out what I’m doing wrong. It’s my first time using react so I’m likely making a simple error. I appreciate anyone’s help.

>Solution :

Since you have created the app using CRA, Can you check if there is already a root.render() method being called inside the index.js file which is showing the splash screen.

The default template of CRA has the root.render method inside the index.js file with App imported from App.js file.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading