Posts

Showing posts with the label ReactJS

What is ReactJS Component API?

Image
In this tutorial we are reading about  “ What is ReactJS Component API ?”. There are three methods to be explained in the React Component API setState() forceUpdate() ReactDOM.findDOMNode() Instead of a React Component are created internally in React when rendering.These instances are reused in subsequent renders,and can be accessed in your component methods as this. Set State setState()  method is used for  updating  the state of the component. State method is useful to add the changes to the original state but it will not replace the state. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 import  React from  'react' ; class  App  extends  React. Component   { constructor ( )   { super ( ) ; this . state   =   { data :   [ ] } this . setStateHandler   =   this . setStateHandler . bind ( this ) ; } ; setStateHandler ( )   { var  item  =   "setState..." v...

States and Props in ReactJS

In this article we are reading about  “ States and Props in ReactJS ”. Dynamic apps must need to pass data around it’s system. In React, data movement happens mostly among components and external services that provide the original data (eg HTTP, localStorage). Props are immutable and dumb which means they can only be passed from parent components down and cannot be changed. This poses a challenge because, modern apps do not rely on having all of it’s states ready on page load. Ajax or Events could happen and when data returns, someone needs to be responsible for making updates. This is where React states comes in. On initializing React, we define an initial state and keep the state in sync with the props. Once the state is updated, the props can then be easily kept in sync: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 //js var  Counter  =  React. createClass ( { getInitialState :   function ( ) ...