Js reaction
when creating an application using React, you can create components / views in two ways.
Jsx
- JSX is a separate technology from React and fully optional when creating a React application, however it makes life much easier when combining JSX with React.
Let's see how:
Approach 1: Standard Response
(function() {
var element = React.DOM.div({}, "Hello World");
ReactDOM.render(element, document.getElementById("app"));
})();
.
react react-dom .
. JSX, Babel.
2: JSX
(function() {
var HelloWorld = React.createClass({
render : function() {
return (
<div> Hello World </div>
);
}
});
var element = React.createElement(HelloWorld, {});
ReactDOM.render(element, document.getElementById("app"));
})();
.
: <div> Hello World </div> JavaScript. JSX.
JSX JavaScript-:
JSX HTML- , HTML, .
JSX - , HTML JavaScript.
, JSX?.
, JSX , . .
Transpiling
.
/ (
)
type="text/babel" script, JSX
- - ,
, webpack ..
.
, .