0

I have started Learning React a few months ago then quitted. And today, I decided to come back to it so I did:

npm init
npm install
npm start

Everything went fine (No Errors) except that nothing is being rendered on the screen! So I tried logging something inside src/index.js... with nothing being logged to the console. I also tried attaching the debugger after adding a breakpoint inside src/index.js and it never got there.

I am very new to React so it might be a stupid question but any help will be great.

Index.html:

<html>
  <head>
    ...
  </head>
  <body>
    <div id="root"></div>
  </body>
</html>

and my src/index.js:

imports...

console.log("index.js");

ReactDOM.render(
    <div>
        <h1>Hellow World</h1>
    </div>,
    document.getElementById('root')
);

Update1

Here is my GitHub repo link, heads up; I simplified my code to make the question clear.

Amer Alahmar
  • 327
  • 1
  • 2
  • 11

2 Answers2

1

Your repo is working fine on sandbox environment check you local configuration like node etc..

https://codesandbox.io/s/github/AmerAlahmar/random-quote-machine2

MUHAMMAD ILYAS
  • 1,297
  • 6
  • 21
0

As @MUHAMMAD said, The problem occurred because I had my "homepage":"..." in my package.json set to my Github README file. like this:

  "homepage": "https://github.com/AmerAlahmar/random-quote-machine2#readme"

I am not sure why and when did that happen but according to this article, a simple "." fixed it:

  "homepage": "."

This might lead you to the next question: What if I want to host my React app on Github while still work on it locally?

this question and this article might help.

Amer Alahmar
  • 327
  • 1
  • 2
  • 11