0

I am copying exact code as tutorial. But my code is not rendering.

*import React from "react";
 import ReactDom from "react-dom";
 const element = <h1>Hello world</h1>;
 ReactDom.render(element, document.getElementById("root"));
 *

Anyone please help. I am trying to learn react from scratch.

5
  • 2
    You need to provide more details about what you are trying, what you are seeing, and the details around how you are attempting to run this. With this alone it is impossible to tell what problem you are facing. Commented Feb 3, 2020 at 16:04
  • Are you using create-react-app? How are you trying to make react render? And are you seeing an error? Commented Feb 3, 2020 at 16:04
  • import ReactDOM from "react-dom"; Commented Feb 3, 2020 at 16:05
  • No error while compiling but element is not printing in browser. Commented Feb 4, 2020 at 11:48
  • Thanks guys it was not working on Internet Explorer.I tried it on chrome it worked fine !! Commented Feb 4, 2020 at 13:18

1 Answer 1

1

try

import React from "react";
import ReactDom from "react-dom";

const Element = () => <h1>Hello world</h1>;
ReactDom.render(<Element/>, document.getElementById("root"));

Otherwise, there is something set up elsewhere in your project

Sign up to request clarification or add additional context in comments.

1 Comment

SCRIPT1028: SCRIPT1028: Expected identifier, string or number This error when is console.log(element) in console after inspecting page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.