Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript React Basics First Steps in React Create a React Element

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

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.

Julianna Kahn
Julianna Kahn
20,701 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);

Thanks Juan. I got it working.