I highly suggest starting here: https://reactjs.org/tutorial/tutorial.html
You can control rerendering via lifecycle events (specifically shouldComponentUpdate()) but don't worry about that for now.
Think of state as everything your component needs to keep track of. It's just an object that you can update and use to move data around your component.
Generally React is written server side, transpiled, and then served. Babel-js is a transpiler for Javascript, and makes it compatible with older stands (basically turns ESNext into ES5). This is normally handled VIA webpack. If you are playing around with React then use create react app to see this in action.
var HelloComponent2 = React.createClass({
render: function() {
return(
<h1>Hello, classical</h1>
);
}
});
is not really modern react. I'm not sure where you learned that but it's very old (though some people do still write react this way imo it's a needless pain). The reason you get undefined error is because React is picky with casing, everything is pascal case so you want to say React.CreateClass. However, I'd suggest trying this modern syntax instead:
class HelloComponent2 extends React.Component {
constructor(props){
super(props);
this.state = {name: props.name}
}
render(){
return(
<h1>Hello, {this.state.name}</h1>
)
}
}
ReactDOM.Render(
<HelloComponent2 name="DCR" />,
document.getElementById("root"))
Check out the official React tutorial to learn more about this stuff. I also highly recommend https://www.tylermcginnis.com his course on React and ES6 is pretty good