jesse
jesse

Reputation: 133

React download for offline usage

I want to download and use react on a network that has no Internet connectivity. I downloaed the zipped source code file at bottom of this page. https://github.com/facebook/react/releases/tag/v16.8.6

It does not seem as straight forward as when you download jquery.js and simply point to it like <script src="jquery.js"></script>. What is the correct way to utilize react on offline network and how should I be pointing to the correct js "src" files? Thank you.

Upvotes: 3

Views: 5426

Answers (2)

Yashshree Shinde
Yashshree Shinde

Reputation: 1

Include these inside your html file

<script src="../babel.min.js"></script>
<script src="../react.development.js"></scriptt>
   <script src="../react-dom.development.js"></script>

       <script type="text/babel src="Your js file source">

Upvotes: 0

0DDC0
0DDC0

Reputation: 5189

You need to DONWLOAD and include all of the following

react : https://unpkg.com/react@16/umd/react.production.min.js
react-dom : https://unpkg.com/react-dom@16/umd/react-dom.production.min.js
babel : https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.25.0/babel.min.js

Include these inside your html file

<script src="react.production.min.js" />
<script src="react-dom.production.min.js" />
<script src="babel.min.js" />

<!-- Your react scripts that you will be coding in -->
<script src="my-script.js" />

Then set up a div with some id in your same html file .

<div id="root" />

In your my-script.js code add some react and render it to the div like this

function MyFirstReactComponent(){
    return <div> My First React Component ! </div>
}

ReactDOM.render(     
  <MyFirstReactComponent />,
  document.getElementById('root')        
);

This should work for you!

The key hear is the addition of Babel which transforms your react code(JSX) to browser understandable Javascript. Also important, the 'ReactDOM' lib which is react's way of interacting with the browser's DOM API.

Upvotes: 5

Related Questions