I am new in react. I want to start a small hello world example of my own.
Most tutorials offer something like this:
app.js
var React = require('react');
var ReactDOM = require('react-dom');
var reactElement = React.createElement('h1', { className: 'header' },
'This is React');
ReactDOM.render(reactElement, document.getElementById('react-
application'));
index.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="x-ua-compatible" content="ie=edge, chrome=1" />
<title>Snapterest</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/
bootstrap/3.3.5/css/bootstrap.min.css">
</head>
<body>
<div id="react-application">
I am about to learn the essentials of React.js.
</div>
<script src="./app.js"></script>
</body>
</html>
The problem is that that example requires nodeJS (for the require() part) and npm install and npm start.. all of that.
I can do it differently without nodeJS like this
app.js
var reactElement = React.createElement('h1', { className: 'header' },
'This is React');
ReactDOM.render(reactElement, document.getElementById('react-application'));
index.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="x-ua-compatible" content="ie=edge, chrome=1" />
<title>Snapterest</title>
<script src=" /react-0.14.8.min.js"></script>
<script src=" /react-dom-0.14.8.min.js"></script>
</head>
<body>
<div id="react-application">
dsf
</div>
<script src="./app.js"></script>
</body>
</html>
in this example I am using cdn in order to import the dependencies of react that nodejs should import in the npm install phase. question is - which is better? could I use just cdn and not use nodejs entirely? is it more correct to have nodejs and npm modules (or bower..) to have the react stuff?
Thanks