14
Learn React.js with me! @KIPROSH By Shivani Thakur

Learn react.js with me!

Embed Size (px)

Citation preview

Page 1: Learn react.js with me!

Learn React.js with me!

@KIPROSHBy Shivani Thakur

Page 2: Learn react.js with me!

Guess what it is???

Page 3: Learn react.js with me!

Still thinking?? Ok then Guess this...

Page 4: Learn react.js with me!

Still not sure…. Guess this one !

Page 5: Learn react.js with me!

JSX => SIMPLEJSX is easy and simple to read and understand :)React.DOM => ComplicatedReact.DOM end up getting complicated as more & more nodes gets added it ….

It’s nothing but JSX Vs React.DOM !!

Page 6: Learn react.js with me!

DO BELIEVE ME :(Then Check

This Out

Page 7: Learn react.js with me!

React.DOM Sample

BirthDayRow = React.createClass({ render: function() { return DOM.div({className: 'row', id: "bday-row1"}, DOM.div({className: 'columns'}, "How to make things complicated"), DOM.div({className: 'columns'}, DOM.div({className: 'row'}, DOM.div({className: 'columns'},"Hi"), DOM.div({className: 'columns'}, "Complicated!")

)))}});

Page 8: Learn react.js with me!

JSX lets us create JavaScript objects using HTML syntax. So it is easy to write.var BirthDayRow = React.createClass({render: function(){ <div id='bday-row1' className='row'> <div className='columns'>How to make things COMPLICATED => SIMPLE</div> <div className='columns'>

<div className='row'><div className='columns'>Hi</div><div className='columns'>Simple!</div>

</div></div>

</div>} });

JSX Sample

Page 9: Learn react.js with me!

Life is REALLY simple :) and if you really want to keep it simple then use => “ JSX ”But if you insist to make it complicated then use=> “ React.DOM ”

Wisdom Quote :)

Page 10: Learn react.js with me!

Component is nothing but a function which takes input params as "Props" and "State". Using these input parameters it will render a dynamic HTML

*NOTE - Main limitation of the component is, "Render single node" only. If you return multiple nodes that will not be render. You have to wrap multiple nodes into single node

Component

Page 11: Learn react.js with me!

Immutable => An immutable object is an object whose state cannot be modified after it is created."Props" (properties) is immutable within the component.

Mutable => Mutable object is an object which can be modified after it is created.

Immutable - Mutable

Page 12: Learn react.js with me!

Once component is there we would like to have some interactions in component. And for that React introduces “State”. State is private to “Component” and can change it by calling “this.setState”

e.g. when I click button and want to show a message i.e. an interaction

State

Page 13: Learn react.js with me!

Inputs to the component are called as props (properties) and we pass them as attribute in JSX or React.DOM

Props are passed from the parent and are "owned" by the parent.

Property

Page 14: Learn react.js with me!

Start Learning!