Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript React Basics (2018) 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,702 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.