Posts

Showing posts with the label Programmers

Understanding the React Component Lifecycle

In this article we are reading about  “ Understanding the React Component Lifecycle ”. React  enables to create components by invoking the React.createClass() method which expects a  render  method and triggers a lifecycle that can be hooked into via a number of so called lifecycle methods. Understanding the component lifecycle will enable you to perform certain actions when a component is created or destroyed. Further more it gives you the opportunity to decide if a component should be updated in the first place and to react to props or state changes accordingly. We know that ReactJS is a component based javascript library. In every ReactJS application components are rendered onto virtual DOM. Before/After rendering onto the virtual DOM every component goes through some of the methods. We call these methods as ReacjJS Component Lifecycle Methods. We can categorize these methods into three based on component initialization, updation and destruction. They are ...

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 ( ) ...

What is JavaScript Variable

Image
In this article, we are reading about “ What is JavaScript Variable “. A  JavaScript variable  is simply a name of the storage location. There are two types of variables in JavaScript: local variable and global variable. There are some rules while declaring a JavaScript variable (also known as identifiers). The name must start with a letter (a to z or A to Z), underscore( _ ), or dollar( $ ) sign. After the first letter, we can use digits (0 to 9), for example, value1. JavaScript variables are case sensitive, for example x and X are different variables. A real-life analogy We can easily grasp the concept of a “variable” if we imagine it as a “box” for data, with a uniquely-named sticker on it. For instance, the variable message can be imagined as a box labeled  “message”  with the value  “Hello!”  in it: We can put any value into the box. Also, we can change it. The value can be changed as many times as needed: 1 2 3 4 let m...