Introduction
React js framework was developed by Facebook.
To include react in our HTML application.
- <scriptsrc="https://fb.me/react-0.12.2.js"></script>
- <scriptsrc="https://fb.me/JSXTransformer-0.12.2.js"></script>
- <scripttype="text/jsx"src="main.jsx">
- </script>
- React.render(
- <h1>hello World 1234</h1>,
- document.body
- );
- var Hello = React.createClass({
- render: function() {
- return<p>Hello, world!</p>;
- }
- });
- React.render(
- <Hello>,
- document.body
- );
- React.render(
- newHello(),
- document.body
- );
- var Hello = React.createClass({
- render: function() {
- return<p>{this.props.message}</p>;
- }
- });
- React.render(
- newHelloWorld({ message: "Hi, Hello World" }),
- document.body
- );
We are passing data through property message and binding that with html tags. This is the actual use of props.
- var Counter = React.createClass({
- getInitialState: function() {
- return {
- count: 0
- };
- },
- increment: function() {
- this.setState({
- count: this.state.counter + 1
- });
- },
- render: function() {
- return <div>
- <div>
- {
- this.state.count
- } </div> <buttononClick={ this.increment }> Click me </button> </div>;
- }
- });
- React.render(new Counter(), document.body);
- var Hello = React.createClass(
- {
- render: function()
- {
- return <p > hello nested class application < /p>;
- }
- });
- varnestedHello = React.createClass(
- {
- render: function()
- {
- return <Hello /> ;
- }
- });
- React.render(
- new Hello(),
- document.body
- );

SubashPosted Sep 28, 2016, 2:16 AM
Nice sir new info for me