JavaScript React Basics First Steps in React Create a React Element

James Roberts
James Roberts
10,167 Points

How to run this code in your own editor?

I'm a little confused. How do I run this code using my own text editor? I'm using Visual Studio. When I open the html file in browser, I get to failed to load resource errors and an uncaught reference error in the console. Do I need to set up my own server?

3 Answers

Juan Lopez
Juan Lopez
Treehouse Project Reviewer

Hey James, great question. In the previous lesson in the teachers notes there was a link on how to setup a local HTTP server. Setup Local Server.

Although if you would like since you mentioned that you are using Visual Studio Code for a text editor you could also search for the Live Server extension or click the link.

Once installed and you start the server you'll be able to go to localhost:8000(like Guil does) if you follow the teacher's notes version or localhost:3000(by default) if you use Live Server.

James Roberts
James Roberts
10,167 Points

Thanks Juan. I got it working.

Julianna Kahn
Julianna Kahn
15,687 Points

I have installed live server but nothing shows on the local host site when I save changes. It just shows:
"Change detected /Users/julianna/Desktop/scoreboard/app.js"

However, I note that the terminal window shows port 5500 and the window opens in port 8080. Is it possible my code is wrong?

const title = React.createElement( 'h1', {id: 'main-title', title: 'This is my title.'}, 'My First React Element!' );

console.log(title);