简体   繁体   中英

How do I install ReactJS locally?

I've tried reading over the "guide" on their website, and none of it makes sense to me. I thought it'd be the same thing as JQuery, but apparently I'm missing something.

I have this appended in my html document (where it's appropriate of course):

<script src="respond.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://unpkg.com/react@latest/dist/react.js"></script>
<script src="https://unpkg.com/react-dom@latest/dist/react-dom.js"></script>
<script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script>
<script src="app.js"></script>
<script type="text/babel" src="app_2.js"></script>

As you might have guessed, I'm using Adobe Dreamweaver to develop my webpage.

That is what the first script element is for. The second being for JQuery.

After running an "example" for ReactJS with JSX, I found the three following script elements in the html document. That, to me, tells me that all I had to do in order to get it working is link those in as well.

Long story short: it didn't work. I tested it on Firefox and Chrome.

The thing I'm still scratching my head over is the error I receive when trying to view the remote files for the ReactJS-related files (on DW):

Not found: package "filename%version"

Where filename is the name of the JS file and version is the version (I'm assuming).

This only occurs for those files and not for JQuery. DW still let's me know that the file is remote and cannot be altered, but I get nothing for the other remote files.

What gives?

I was able to get it working after some scrambling, reading, and random attempts.

Turns out I was getting in my own way.

Because of the tutorial I was learning react from, I had assumed I was required to always create a react object and react-dom object.

After removing those two declarations from my js file, I was able to then see the expected results in my browser.

The only thing I can think of as to why those declarations would cause an issue is either because one of the files I import already does so (which has to happen as I don't declare the "React" or "React-dom" instances anymore but am still able to use them) or it is no longer required explicitly. The tutorial I went through was a bit dated.

I'm gonna have so much fun with this!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM