# Problems getting started with React?

**URL:** <https://forum.freecodecamp.org/t/problems-getting-started-with-react/393823>\
**Category:** General\
**Created:** [May 25, 2020, 7:02am UTC](https://forum.freecodecamp.org/t/problems-getting-started-with-react/393823 "2020-05-25T07:02:25Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![torentrap](https://avatars.discourse-cdn.com/v4/letter/t/9fc29f/32.png) [@torentrap](https://forum.freecodecamp.org/u/torentrap)\
**Post date:** [May 25, 2020, 7:02am UTC](https://forum.freecodecamp.org/t/problems-getting-started-with-react/393823/1 "2020-05-25T07:02:25Z")

</div>

Hi all,  
I’m trying to run React on my laptop. I’m using notepad++.  
I’ve added these three lines , above the tag:

```auto
<script src="https://unpkg.com/react@16/umd/react.development.js" crossorigin></script>  
	<script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js" crossorigin></script>
	<script src="reactfile.js" type="text/babel"></script>

```

the reactfile.js is my react file.  
I addes these line to test:

```auto
ReactDom.render(<p>testing</p>,document.getElementById("react-test"));

```

So shouldn’t it add the word “testing” in a § tag on my page?  
There is a div tag that has the id of “react-test” , above the 3 script lines.

I can see nothing added to my page so I’m not sure if it’s working or if I’m doing something wrong?

Thanks so much!  
🙂

---

<div class="post-metadata">

**Author:** ![Annestezia](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/annestezia/32/74275_2.png) [@Annestezia](https://forum.freecodecamp.org/u/Annestezia)\
**Post date:** [May 25, 2020, 10:04am UTC](https://forum.freecodecamp.org/t/problems-getting-started-with-react/393823/2 "2020-05-25T10:04:04Z")

</div>

[What React looks like without es6](https://reactjs.org/docs/react-without-es6.html)  
[What’s babel](http://nicholasjohnson.com/blog/what-is-babel/)  
[The easiest way to create react app](https://reactjs.org/docs/create-a-new-react-app.html#create-react-app)

---

<div class="post-metadata">

**Author:** ![torentrap](https://avatars.discourse-cdn.com/v4/letter/t/9fc29f/32.png) [@torentrap](https://forum.freecodecamp.org/u/torentrap)\
**Post date:** [May 26, 2020, 1:29am UTC](https://forum.freecodecamp.org/t/problems-getting-started-with-react/393823/3 "2020-05-26T01:29:56Z")

</div>

So what did I do wrong, I have no clue reading though those links?  
I’m completely new to React , and this feels a bit overwhelming .

---

<div class="post-metadata">

**Author:** ![astv99](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/astv99/32/66820_2.png) [@astv99](https://forum.freecodecamp.org/u/astv99)\
**Post date:** [May 26, 2020, 4:30am UTC](https://forum.freecodecamp.org/t/problems-getting-started-with-react/393823/4 "2020-05-26T04:30:52Z")

</div>

There are at least a few issues wrong with your code:

1. You don’t have a CDN to Babel referenced in your HTML. Babel needs to be “installed” in order for you to use JSX in your React code.
2. Your “reactfile.js” needs to be a JSX file, not a regular JS file.
3. The first argument to ReactDOM.render() needs to be a component, not regular HTML.

It also no longer works to load an HTML file directly in your browser. That used to work with React 15, but has since been deprecated due to CORS issues. You need to run a basic HTTP server now. You can use the one built into either Python (SimpleHTTPServer), or Node.js ([https://www.npmjs.com/package/http-server](https://www.npmjs.com/package/http-server)).

If you don’t understand what Babel or JSX is, I’d recommend using Google. Also this is a good free starter resource for learning React that’s more accessible than the official docs: [https://flaviocopes.com/page/react-handbook/](https://flaviocopes.com/page/react-handbook/)

Once you understand the basic concepts and know how to set up a basic React app directly via the browser, I’d recommend learning Node.js and create-react-app. It vastly simplifies everything.

---

<div class="post-metadata">

**Author:** ![torentrap](https://avatars.discourse-cdn.com/v4/letter/t/9fc29f/32.png) [@torentrap](https://forum.freecodecamp.org/u/torentrap)\
**Post date:** [May 26, 2020, 5:06am UTC](https://forum.freecodecamp.org/t/problems-getting-started-with-react/393823/5 "2020-05-26T05:06:03Z")

</div>

Thanks for that , I’ll take a look at it all 🙂  
I started with some beginners course on React on youtube but it was from 2016 and didn’t explain anything about setup.

---

<div class="post-metadata">

**Author:** ![astv99](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/astv99/32/66820_2.png) [@astv99](https://forum.freecodecamp.org/u/astv99)\
**Post date:** [May 26, 2020, 5:17am UTC](https://forum.freecodecamp.org/t/problems-getting-started-with-react/393823/6 "2020-05-26T05:17:40Z")

</div>

The current version of React is 16 which came out in September 2017, so I’d recommend not learning from any resources dated before then, which will refer to React 15. 15 is obsolete; see the link below for info on how naming in software is basically versioned. Anytime software gets updated to a new major version, stuff inevitably breaks, and you have to learn most things anew.

> **[Semantic Versioning 2.0.0](https://semver.org/)**
>
> Semantic Versioning spec and website

---

<div class="post-metadata">

**Author:** ![torentrap](https://avatars.discourse-cdn.com/v4/letter/t/9fc29f/32.png) [@torentrap](https://forum.freecodecamp.org/u/torentrap)\
**Post date:** [May 26, 2020, 5:23pm UTC](https://forum.freecodecamp.org/t/problems-getting-started-with-react/393823/7 "2020-05-26T17:23:59Z")

</div>

Thanks for the reply astv99 🙂  
I started reading the book in the link you suggested, and  
very early on it says the react file should be a .js file (with text/bable mime type), so I’m confused why you said my “reactfile.js” needs to be a JSX file?

Sorry if I’m asking too much ,I’m just a bit confused ,hope you don’t mind 🙂

---

<div class="post-metadata">

**Author:** ![astv99](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/astv99/32/66820_2.png) [@astv99](https://forum.freecodecamp.org/u/astv99)\
**Post date:** [May 26, 2020, 5:40pm UTC](https://forum.freecodecamp.org/t/problems-getting-started-with-react/393823/8 "2020-05-26T17:40:11Z")

</div>

It seems like the file extension doesn’t matter as far as getting things actually working. I just tried that and it looks like it runs whether the file is JS or JSX.

But JavaScript files containing React code should still be in JSX format regardless, so I’d consider that an oversight on the author’s part. It’s better to do it that way in your code editor for syntax highlighting.

---

<div class="post-metadata">

**Author:** ![lasjorg](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/lasjorg/32/280761_2.png) [@lasjorg](https://forum.freecodecamp.org/u/lasjorg)\
**Post date:** [May 26, 2020, 6:24pm UTC](https://forum.freecodecamp.org/t/problems-getting-started-with-react/393823/9 "2020-05-26T18:24:09Z")

</div>

I would suggest using [create react app](https://create-react-app.dev/) when working locally and using [Codesandbox](https://codesandbox.io) or [StackBlitz](https://stackblitz.com) for online editors.

BTW, I don’t believe the .jsx extension is all that useful anymore (CRA, do not recommend it).

> <https://github.com/facebook/create-react-app/issues/87>
>
> Note from Maintainers
> We support JSX extension since 0.4.1 even though we don’t recommend it.
> Read the release notes.
> 
> Shouldn't the default be to...

  

> <https://github.com/airbnb/javascript/pull/985#issuecomment-239145468>

---

<div class="post-metadata">

**Author:** ![torentrap](https://avatars.discourse-cdn.com/v4/letter/t/9fc29f/32.png) [@torentrap](https://forum.freecodecamp.org/u/torentrap)\
**Post date:** [May 26, 2020, 7:20pm UTC](https://forum.freecodecamp.org/t/problems-getting-started-with-react/393823/10 "2020-05-26T19:20:47Z")

</div>

Thanks lasJorg. So I will stick to reactfile.js after all. Confusing all 😄

I just installed node.js and I’m running the npx and npm commands from the node cmd prompt, but get error messages?

I typed these in this order:  
npx create-react-app todolist //I saw a success screen after running this  
npm start

after running npm start I see all kinds off error messages ?  
npm err! code ENOENT  
etc

Hope someone can help, thanks! 🙂

---

<div class="post-metadata">

**Author:** ![astv99](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/astv99/32/66820_2.png) [@astv99](https://forum.freecodecamp.org/u/astv99)\
**Post date:** [May 26, 2020, 7:39pm UTC](https://forum.freecodecamp.org/t/problems-getting-started-with-react/393823/11 "2020-05-26T19:39:58Z")

</div>

If you’re coding on Windows, which I assume you are from the Notepad++ reference, you need to run Command Prompt as an Administrator. Or I’d recommend using this: [https://cmder.net/](https://cmder.net/)

---

<div class="post-metadata">

**Author:** ![torentrap](https://avatars.discourse-cdn.com/v4/letter/t/9fc29f/32.png) [@torentrap](https://forum.freecodecamp.org/u/torentrap)\
**Post date:** [May 26, 2020, 7:49pm UTC](https://forum.freecodecamp.org/t/problems-getting-started-with-react/393823/12 "2020-05-26T19:49:42Z")

</div>

Thanks, how do you know all this ? I feel I know nothing yet 😛  
I tried it though, and I still get the same error message list ?

Edit : I typed :

```auto
cd todolist  

```

and then :

```auto
 npm start 

```

& now it works! 🙂

---

<div class="post-metadata">

**Author:** ![astv99](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/astv99/32/66820_2.png) [@astv99](https://forum.freecodecamp.org/u/astv99)\
**Post date:** [May 26, 2020, 8:39pm UTC](https://forum.freecodecamp.org/t/problems-getting-started-with-react/393823/13 "2020-05-26T20:39:10Z")

</div>

> [@torentrap](#):
>
> Thanks, how do you know all this ? I feel I know nothing yet

I’ve been at this coding thing for a while myself. 😉 Btw if you’re still using Notepad++, I’d recommend using this instead: [https://code.visualstudio.com/](https://code.visualstudio.com/)

Notepad++ is fine as a general-purpose editor but since it doesn’t have syntax highlighting for React, you should use something that does.

---

<div class="post-metadata">

**Author:** ![Fastersun](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/fastersun/32/151110_2.png) [@Fastersun](https://forum.freecodecamp.org/u/Fastersun)\
**Post date:** [May 28, 2020, 2:07pm UTC](https://forum.freecodecamp.org/t/problems-getting-started-with-react/393823/14 "2020-05-28T14:07:27Z")

</div>

I have no clue reading though those links?

---

<div class="post-metadata">

**Author:** ![torentrap](https://avatars.discourse-cdn.com/v4/letter/t/9fc29f/32.png) [@torentrap](https://forum.freecodecamp.org/u/torentrap)\
**Post date:** [May 28, 2020, 8:29pm UTC](https://forum.freecodecamp.org/t/problems-getting-started-with-react/393823/15 "2020-05-28T20:29:58Z")

</div>

Edit: never mind, I’ve decided to finish reading my JS and Jquery books , and spend more time learning those two before I start with React.  
I will revive this thread when I need help again, thanks 🙂

So now I’m stuck again.  
I managed to get to the point where I run “npm start” in the node.js cmd prompt .

When I open the file I created through " npx react-create-app todolist" , todolist (it’s under windows32), I see a list of files , with no index.html file.?  
I was following a tutorial on youtube that used visual studio and they had a index.html (with an id of root) ? I’m also reading a react book but it hasnt’ explained this yet.

Do I need visual studio for this to work, or do I use my own index.html file that I add to this system32/todolist file? And do I edit the js /css files that are in this list if I want to code react?

This is soo confusing !! :unamused

Thanks for any help! 🙂

---

<div class="post-metadata">

**Author:** ![lasjorg](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/lasjorg/32/280761_2.png) [@lasjorg](https://forum.freecodecamp.org/u/lasjorg)\
**Post date:** [May 29, 2020, 1:33am UTC](https://forum.freecodecamp.org/t/problems-getting-started-with-react/393823/16 "2020-05-29T01:33:34Z")

</div>

You should not create the app inside system folders, that is a really bad idea. That happened because you ran the Node.js command prompt as admin. Doing that will open it up inside the System32 folder. Install the app inside a “normal” user folder.

The index.html file is inside the `public` folder.

Install the app using create-react-app into a folder of your choice.

> **Steps (there are different ways to do it, this is just one way)**
>
> 1. Install [VS Code](https://code.visualstudio.com/)
> 
> 2. Create a “projects” folder inside your “Documents” folder
> 
> 3. Create a “todolist” folder inside “projects” folder
> 
> 4. Right-click the “todolist” folder and from the right-click menu select “Open with Code”
> 
> 5. Inside VS Code open the build-in terminal. From the menu `View` select `Terminal`, take note of the hotkey in the menu so you can use that instead of from now on
> 
> 6. Run `npx create-react-app .` (using `.` will create an app using the current folder name as the app name, i.e. todolist).

Visual Studio and Visual Studio Code (VS Code) are not the same programs. You do not need any of them to write React code but I would suggest using VS Code anyway.

As for how, and where to write the code you are better off looking at some React crash course articles and videos.

> **[Courses – React](https://reactjs.org/community/courses.html)**
>
> A JavaScript library for building user interfaces

---

<div class="post-metadata">

**Author:** ![torentrap](https://avatars.discourse-cdn.com/v4/letter/t/9fc29f/32.png) [@torentrap](https://forum.freecodecamp.org/u/torentrap)\
**Post date:** [May 29, 2020, 3:48am UTC](https://forum.freecodecamp.org/t/problems-getting-started-with-react/393823/17 "2020-05-29T03:48:31Z")

</div>

Thanks for the reply lasjorg, I think I’m getting the hang of this now(slowly) 🙂

I also found a very helpful course in case anyone is interested:

> **[A Beginners Guide to React Introduction](https://egghead.io/lessons/react-a-beginners-guide-to-react-introduction)**
>
> Welcome to The Beginner’s Guide to React! I’m happy you’re here. I recommend that you watch all of these videos through once without touching the keyboard. Just take notes. Then you can watch them a second time and follow along and change/break the...

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [June 1, 2021, 6:51pm UTC](https://forum.freecodecamp.org/t/problems-getting-started-with-react/393823/18 "2021-06-01T18:51:47Z")

</div>

Closed on June 1, 2021, 6:51pm UTC


