0

Code pen link here.

In my fist ReactJS tutorial video, I was writing hello world script and disappointingly its not working. I am not seeing any problem with the script or html tags I used but simple ReactDOM.Render() function isn't working. Code pen SS below. enter image description here

As you can see, the HTML block has root div HTML block:

<div id="root">Why ReactDOM.Render() not working?</div>

JS(Babel) block has simple render function and in the right side pane the preview is showing default text in root element but not the text.

JS block:

var el = <h1>YOU HELLO WORLD WHY DONT YOU WORK</h1>
ReactDOM.Render(
el,
  Document.getElementById("root")
)

1 Answer 1

2

JavaScript is case-sensitive.

Try:

ReactDOM.render(
   el,
   document.getElementById("root"),
);

And remember to import React as well as ReactDOM.

https://codepen.io/anon/pen/REaEBo

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

2 Comments

Document also should be lower-case.
though the case senstive was visible error I was doing, earlier the code I copied from tutorials also didn't work because I missed the steps to add react and react-dom as instructed in project setup. Thanks

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.