[React] React Fundamentals: First Component
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title>React Lesson 0</title> </head> <body> <script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.12.2/react.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.12.2/JSXTransformer.js"></script> <script type="text/jsx"> //First way: ReactApp, the first letter should be capitialize var React_app = React.createClass({ render: function() { return <h1>Hello React World!</h1> } }); React.render(<React_app />, document.body); //second way: /*var App = React.createClass({ render: function(){ return React.DOM.h1(null, 'Hello React DOM'); //1: attr, 2: value } }); React.render(App(), document.body);*/ //Third way: /*var App = React.createClass({ render: function() { return React.createElement("h1", null, "Hello React Element"); //1: tag, 2: attr, 3: value } }); React.render(React.createElement(App), document.body);*/ </script> </body> </html>