<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Shashidhar Reddy on Medium]]></title>
        <description><![CDATA[Stories by Shashidhar Reddy on Medium]]></description>
        <link>https://medium.com/@reddyeshashidhar?source=rss-86665ccbadd2------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Z_qyVBtQkkfE2qyJYxyw3A.jpeg</url>
            <title>Stories by Shashidhar Reddy on Medium</title>
            <link>https://medium.com/@reddyeshashidhar?source=rss-86665ccbadd2------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 03:27:01 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@reddyeshashidhar/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to Use FETCH API for CRUD Operation.]]></title>
            <link>https://medium.com/@reddyeshashidhar/how-to-use-fetch-api-for-crud-operation-4554fc18b72f?source=rss-86665ccbadd2------2</link>
            <guid isPermaLink="false">https://medium.com/p/4554fc18b72f</guid>
            <dc:creator><![CDATA[Shashidhar Reddy]]></dc:creator>
            <pubDate>Sat, 08 Aug 2020 04:21:17 GMT</pubDate>
            <atom:updated>2020-08-08T04:21:17.387Z</atom:updated>
            <content:encoded><![CDATA[<p>What is CRUD Operation?</p><p>CRUD stands for Create, Read, Update and Delete.</p><p>Create is inserting the new data.</p><p>Read is getting the data.</p><p>Update is modifying or updating the existing data.</p><p>Delete will delete the existing data.</p><h4>HTTP Requests:</h4><p>1.When we want to create a new row we will call a POST Request.</p><p>Post will be sending data to a server.</p><p>2.When we want to read the data from DB. Then we will be using GET Request.</p><p>Get is used to get the data from the server.</p><p>3.If we want to modify/ update some data in data then we will be doing PUT Request.</p><p>Put is used to send data to server to update a particular field.</p><p>4.If we want to delete something from DB.</p><p>Delete is used to delete the specific field.</p><p>Now, Let us dive in</p><p>If you wanna perform CRUD operation using Fetch API you need a REST API Server.</p><p>JSONPlaceholder is a free online REST API.</p><p>https://jsonplaceholder.typicode.com/</p><p>Syntax:</p><p>fetch(url)</p><p>// you will be hitting the url</p><p>.then( ()=&gt; {})</p><p>.catch(()=&gt; {});</p><h3>GET:</h3><p>fetch(’https://jsonplaceholder.typicode.com/posts/1’) .then(response =&gt; response.json()) .then(json =&gt; console.log(json))</p><p>// Output { id: 1, title: &#39;[...]’, body: &#39;[...]’, userId: 1 }</p><h3>POST:</h3><p>For post call we should pass the method POST.</p><p>Creating a resource.</p><p>fetch(’https://jsonplaceholder.typicode.com/posts’, { method: &#39;POST’, body: JSON.stringify({ title: &#39;foo’, body: &#39;bar’, userId: 1 }), headers: { &quot;Content-type&quot;: &quot;application/json; charset=UTF-8&quot; } }) .then(response =&gt; response.json()) .then(json =&gt; console.log(json)</p><p>// Output</p><p>{ id: 101, title: &#39;foo’, body: &#39;bar’, userId: 1 }</p><p>Update a resource</p><h3>With PUT</h3><p>Here, we are updating the resource with id =1.</p><p>fetch(&#39;https://jsonplaceholder.typicode.com/posts/1&#39;, { method: &#39;PUT&#39;, body: JSON.stringify({ id: 1, title: &#39;foo&#39;, body: &#39;bar&#39;, userId: 1 }), headers: { &quot;Content-type&quot;: &quot;application/json; charset=UTF-8&quot; } }) .then(response =&gt; response.json()) .then(json =&gt; console.log(json))</p><p>// Output</p><p>{ id: 1, title: &#39;foo&#39;, body: &#39;bar&#39;, userId: 1 }</p><h3>Delete a resource:</h3><p>fetch(&#39;https://jsonplaceholder.typicode.com/posts/1&#39;, { method: &#39;DELETE&#39;, })</p><p>It will delete the resource with id = 1.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4554fc18b72f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Spring Boot with JdbcTemplate]]></title>
            <link>https://medium.com/@reddyeshashidhar/spring-boot-with-jdbctemplate-9b53b4daf2aa?source=rss-86665ccbadd2------2</link>
            <guid isPermaLink="false">https://medium.com/p/9b53b4daf2aa</guid>
            <category><![CDATA[lombok]]></category>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Shashidhar Reddy]]></dc:creator>
            <pubDate>Thu, 26 Dec 2019 04:38:44 GMT</pubDate>
            <atom:updated>2019-12-26T04:38:44.894Z</atom:updated>
            <content:encoded><![CDATA[<p>What all we need as system set up:</p><ol><li>JDK 8</li><li>Spring Boot</li><li>Intellij Idea/ eclipse</li><li>Maven</li></ol><p>Let’s go into the application:</p><p>pom.xml</p><pre>&lt;properties&gt;<br>        &lt;java.version&gt;1.8&lt;/java.version&gt;<br>    &lt;/properties&gt;<br>    &lt;parent&gt;<br>        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>        &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;<br>        &lt;version&gt;1.3.3.RELEASE&lt;/version&gt;<br>    &lt;/parent&gt;<br>	<br>    &lt;dependencies&gt;<br>	&lt;dependency&gt;<br>            &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>            &lt;artifactId&gt;spring-boot-starter-jdbc&lt;/artifactId&gt;<br>        &lt;/dependency&gt;<br>	&lt;dependency&gt;<br>            &lt;groupId&gt;mysql&lt;/groupId&gt;<br>            &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;<br>	&lt;/dependency&gt;<br>		<br>	&lt;dependency&gt;<br>            &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>            &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;<br>	    &lt;scope&gt;test&lt;/scope&gt;<br>        &lt;/dependency&gt;<br>    &lt;/dependencies&gt;<br>	<br>	&lt;build&gt;<br>		&lt;plugins&gt;<br>			&lt;plugin&gt;<br>				&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>                                &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;<br>			&lt;/plugin&gt;<br>		&lt;/plugins&gt;<br>	&lt;/build&gt;</pre><p>Our Application class:</p><pre>package com.springproject;<br>import org.springframework.boot.SpringApplication;<br>import org.springframework.boot.autoconfigure.SpringBootApplication;<br>@SpringBootApplication(scanBasePackages = &quot;com.springproject&quot;)<br>public class Application {<br>	<br>    public static void main(String[] args) {<br>        SpringApplication.run(Application.class, args);<br>    }<br>}</pre><p>Lets create a basic model class</p><pre>package com.springproject.model;<br>public class User {<br>    private String name;<br>    private String address;<br>    private String email;<br>	<br>    public String getName() {<br>        return name;<br>    }<br>    public void setName(String name) {<br>        this.name = name;<br>    }<br>    public String getAddress() {<br>        return address;<br>    }<br>    public void setAddress(String address) {<br>        this.address = address;<br>    }<br>    public String getEmail() {<br>        return email;<br>    }<br>    public void setEmail(String email) {<br>        this.email = email;<br>    }<br>}</pre><p>You can install Lombok/add dependency in pom.xml and use some of its features like generating a getters and setters.</p><pre><strong>import </strong>lombok.Getter;<br><strong>import </strong>lombok.Setter;</pre><pre>@Getter<br>@Setter<br>public ClassName{<br>}</pre><p>UserDaoImpl</p><pre>package com.springproject.dao.impl;<br>import java.sql.Connection;<br>import java.sql.PreparedStatement;<br>import java.sql.ResultSet;<br>import java.sql.SQLException;<br>import java.sql.Statement;<br>import java.util.List;<br>import org.springframework.beans.factory.annotation.Autowired;<br>import org.springframework.jdbc.core.JdbcTemplate;<br>import org.springframework.jdbc.core.PreparedStatementCreator;<br>import org.springframework.stereotype.Repository;<br>import com.springproject.dao.UserDao;<br>import com.springproject.model.User;<br>@Repository<br>public class UserDaoImpl implements UserDao {<br>	private final String INSERT_QUERY = &quot;INSERT INTO USERS(name,address,email) values(?,?,?)&quot;;<br>	private final String FETCH_QUERY = &quot;select name, address, email from users&quot;;<br>	@Autowired<br>	private JdbcTemplate jdbcTemplate;<br>	public User create(final User user) {<br>		KeyHolder holder = new GeneratedKeyHolder();<br>		jdbcTemplate.update(new PreparedStatementCreator() {<br>			@Override<br>			public PreparedStatement createPreparedStatement(Connection connection) throws SQLException {<br>				PreparedStatement ps = connection.prepareStatement(INSERT_QUERY, Statement.RETURN_GENERATED_KEYS);<br>				ps.setString(1, user.getName());<br>				ps.setString(2, user.getAddress());<br>				ps.setString(3, user.getEmail());<br>				return ps;<br>			}<br>		}, holder);<br>		int newUserId = holder.getKey().intValue();<br>		user.setId(newUserId);<br>		return user;<br>	}<br>	public List findAll() {<br>		return jdbcTemplate.query(FETCH_QUERY, new UserMapper());<br>	}<br><br>class UserMapper implements RowMapper {<br>	@Override<br>	public User mapRow(ResultSet rs, int rowNum) throws SQLException {<br>		User user = new User();<br>		user.setName(rs.getString(&quot;name&quot;));<br>		user.setEmail(rs.getString(&quot;address&quot;));<br>		user.setEmail(rs.getString(&quot;email&quot;));<br>		return user;<br>	}</pre><p>SQL Query:</p><pre>CREATE TABLE users (name varchar(100), address varchar(250), email varchar(100), PRIMARY KEY (record_id));</pre><p>we need to specify the database url , name and password:</p><p>application.properties:</p><pre>spring.datasource.url=jdbc:mysql://localhost/springproject<br>spring.datasource.username=root<br>spring.datasource.password=password123<br>spring.datasource.driver-class-name=com.mysql.jdbc.Driver</pre><p>I hope this gives you basic idea about the jdbctemplate spring boot. I will also plan to implement a detailed one. Thanks :).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9b53b4daf2aa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Important Features of ES6 with Examples]]></title>
            <link>https://medium.com/@reddyeshashidhar/important-features-of-es6-with-examples-99c88b6b0275?source=rss-86665ccbadd2------2</link>
            <guid isPermaLink="false">https://medium.com/p/99c88b6b0275</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[es6]]></category>
            <dc:creator><![CDATA[Shashidhar Reddy]]></dc:creator>
            <pubDate>Wed, 17 Jul 2019 07:05:25 GMT</pubDate>
            <atom:updated>2019-07-18T12:56:23.230Z</atom:updated>
            <content:encoded><![CDATA[<h3>Important Features of Javascript ES6 with Examples</h3><p>ES6 made more features of the javascript look simple and also made easy to use. Lets go through some important features of ES6.</p><h4><strong>1. const and let keywords</strong></h4><p><strong>const- </strong>Name itself tells that it enables you define constant<strong>.</strong>Once you declared like const you can’t change the value.Before ES6 everything was global with var. The variables which are declared by <strong>var</strong> have function scope and hoisted to the top. It means that a variable declared with <strong>var</strong> can be used before it has been declared. <strong>Let</strong> and <strong>const</strong> have block scope({}) and it cannot be used before declaration.<strong>Let</strong> behaves exactly like <strong>var</strong> but it has scope.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1002/1*AkwMMSUNI9zaV0pQen4_mg.png" /></figure><h4><strong>2. Template Literals</strong></h4><p>Template literals is a cool feature. It will direct allows us to plug variables into string directly. Before ES6 we have to concat the variables to have this feature.Below is the example.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ucSYHRD2SPId72m0kjgGFQ.png" /></figure><h4><strong>3.Array Functions</strong></h4><p>Can we solve our problem without using this functions? Yes, ofcourse these functions are not necessary in a language. Then why we are using? These functions make us to reduce the bulk of the code and save the writing similar code where ever we use these functions.If we implement we may break the code so this will be the better way.,</p><p><strong><em>forEach</em></strong></p><p>Executes the provided function for each element of the array, passing the array element as an argument.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vShp5iY5uee9za9j_LXHqg.png" /></figure><p><strong><em>map</em></strong></p><p>They allow you to perform an action to each element in an array, and the results will be in new array.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/830/1*GG7TrRs7PJQWlle5XkyVlA.png" /></figure><p><strong>filter</strong></p><p>The result will be the subset of original array. Filter function will checks each element of array and it the test condition is satisfied then will move that element to new array.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/726/1*RU6ochYzVI7-GPDQMSM8BA.png" /></figure><p><strong><em>Reduce</em></strong></p><blockquote>I think this example makes you understand how reduce functions will work:For detailed information click here <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce">reduce-javascript</a></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/932/1*828WNg3KAGQ69DEjQ5mCZQ.png" /></figure><h4>4. Arrow functions</h4><p>Similar to Function. It mainly prevents ‘this’ bugs. It also makes easier to predict the behaviour of this bugs when passed as callbacks. They don’t redefine the value of ‘this’ within their function body.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/564/1*qZmHbA4vlZ0S5nXPMJclTg.png" /></figure><pre>var addition = (x, y) =&gt; x+y;</pre><p>Because of the lightweight syntax, arrow functions are also a great option for anonymous functions. For ‘this,’ you also have an easier time because there isn’t any worry about mutation or losing scope. The arrow functions relies on the implicit return statement.</p><h4>5. Destructing</h4><p>It is the way of getting the values from arrays and objects.In JavaScript ES5, you’d have to write out the name of the object you’re pulling the values from each time you wanted to create a new variable.</p><p>Before ES6:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/726/1*In1d_4nFDj2EkDqvMi1DUA.png" /></figure><p>After ES6:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/762/1*FbOcPKTvuRmKo_WqRwMA9A.png" /></figure><h4><strong>6.Multiline Strings</strong></h4><p>Before ES6</p><pre>var strings= &quot;This is a example\n&quot;<br>+ &quot;of a multi-line string,\n&quot;<br>+ &quot;which plays a important role.&quot;</pre><p>After ES6</p><pre>var strings= `This is a example,<br>of a multi-line string,<br>which plays a important role`</pre><h4>7.Rest and spread operators</h4><p>Spread operators will be used in merging the array and also making a shallow copy of the array. (shallow copy and deep copy is a good concept i will try to make a separate note on that.)</p><p>Shallow copy example:</p><pre>var names = [‘Shashidhar Reddy’, ‘Cijo’, ‘Karthik’, ‘Bharat’]</pre><pre>var names= […names]</pre><p>Merging array</p><pre>var names = [‘Shashidhar Reddy’, ‘Cijo’, ‘Karthik’, ‘Bharat’]</pre><pre>var fewnames= [&#39;Anshad&#39;,&#39;Santhosh&#39;]<br>var mergedArray =[...names, ...fewnames]</pre><h4>8.Promises</h4><p>What is Promise? It is an object that may produce a single value some time in future in three forms i.e. solved one unsolved one and still in progress(pending one). Mainly to build for asynchronous code. If we are writing a lot of code there is no use of setTimeout because we don’t know the exact time that the function has to wait etc.,</p><pre>setTimeout( ()=&gt;{<br> console.log(&#39;Before ES6&#39;);<br>}, 1000);</pre><p>I have written a blog on setTimeout. Here is the link <a href="https://medium.com/@reddyeshashidhar/understanding-how-settimeout-works-and-variations-that-is-shows-with-different-partners-61fbe11af907">setTimeout</a></p><p>Example:</p><pre>const message = new Promise( ( resolve, reject) =&gt; {</pre><pre>resolve(“Hello”);</pre><pre>});</pre><pre>message.then(res =&gt; console.log(`message : ${res}`));</pre><p>You can access the return value of the resolved promise by using .then syntax. Because promise will always returns a promise.</p><p>I found these are important, if i found any new things i will definitely add below. Thanks!! keep coding :) !</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=99c88b6b0275" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding How setTimeout works and variations that is shows with different partners?]]></title>
            <link>https://medium.com/@reddyeshashidhar/understanding-how-settimeout-works-and-variations-that-is-shows-with-different-partners-61fbe11af907?source=rss-86665ccbadd2------2</link>
            <guid isPermaLink="false">https://medium.com/p/61fbe11af907</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[es6]]></category>
            <dc:creator><![CDATA[Shashidhar Reddy]]></dc:creator>
            <pubDate>Fri, 12 Jul 2019 14:33:38 GMT</pubDate>
            <atom:updated>2019-07-12T14:43:56.584Z</atom:updated>
            <content:encoded><![CDATA[<h3>Understanding How setTimeout works and variations that it shows with different partners?</h3><h3>Using For loop printing values from 1 to 10;</h3><p>Why i choose this topic? when i have attended the interview or any basic javascript competition this is one of the topic they will ask.</p><pre>for (let i = 1; i &lt; 10; i++) {<br> console.log(i);<br>}<br>// setTimeout inside a For loop</pre><pre>for (var i = 1; i &lt; 10; i++) {<br> console.log(i);<br>}</pre><p>When we execute the above both programs we will get the following output as 1 2 3 4 5 6 7 8 9</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/825/1*Vx7e8garg81UJ6JYVCHb0Q.png" /></figure><h3><strong>setTimeout()</strong> function:</h3><pre>setTimeout(function(){<br> console.log(‘Hello World!’);<br>}, 2000);</pre><p>This function will print value as “Hello World!” after 2 sec.</p><h3><strong>setTimeout() inside for loop:</strong></h3><p><em>setTimeout</em> executes inside a JavaScript for loop. Here is how the code looks:</p><pre>// setTimeout inside a For loop</pre><pre>for(var i = 0;i &lt; 10; i++){<br>    setTimeout(function(){<br>        console.log(i);<br>    }, 1000);<br>}</pre><p>When we execute the for loop we will think the output will be 1 2 3 4 5 6 7 8 9</p><p>But the output here will be</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/1*rvEzNQ6aPXeb-npkiNlQBg.png" /></figure><p>Surprised! Let’s have a look into the code, why this is happening?</p><p>The setTimeout function callback isn’t triggered until the for loop execution is completed. After completing the for loop then the setTimeout will execute with the final value callback.</p><h4><strong>How to fix it? What is the solution?</strong></h4><p>Here, i found two ways of solving it by using the let keyword and the method is using IIFE(Immediately Invoked Function Expression)</p><h3>1. setTimeout Inside For Loop Using let Keyword</h3><p>Let keyword is introduced recently ES6. The let keyword will keep the value independently i.e. separate scope. So, when any iteration happens it will keep the value separate and print the correct value.Let’s check the code.</p><pre>// setTimeout inside For loop Using let keyword</pre><pre>for(let i = 0;i &lt; 10; i++){<br>    setTimeout(function(){<br>        console.log(i);<br>    }, 1000);<br>}</pre><p>Here is the output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/848/1*pdspVC3HeZ2Tlicsvp0H8w.png" /></figure><p>we can also write the logic in different introducing let variable separately. Here is the code:</p><pre>// setTimeout inside For loop Using let keyword</pre><pre>for(var i = 0;i &lt; 10; i++){<br>    let j = i;<br>        setTimeout(function(){<br>        console.log(j);<br>    }, 1000);<br>}</pre><p>You will be getting the same output as above.Now will look into IIFE.</p><h3>2.setTimeout Inside For Loop Using IIFE (Immediately Invoked Function Expression)</h3><p>What IIFE will do?</p><p>It can be used to create a new scope for each setTimeout callback without disturbing the global scope or parent scope.</p><pre>// setTimeout inside for loop with IIFE and Var keyword</pre><pre>for(var i = 0; i &lt; 10; i++){<br>    (function(i){<br>        setTimeout(function(){<br>            console.log( i);<br>        }, 1000);<br>    })(i);<br>}</pre><pre>// setTimeout inside for loop with IIFE and Let keyword</pre><pre>for(let i = 0; i &lt; 10; i++){<br>    (function(i){<br>        setTimeout(function(){<br>            console.log( i);<br>        }, 1000);<br>    })(i);<br>}</pre><p>When we execute the following output you will get.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/836/1*z6hKn1xtZ0aFe3deM6BuHw.png" /></figure><p>***The examples that are given above are written, executed by me in my system.***</p><p>So,I think this Blog may help you. Now, let us make our hands dirty by running shitty code all around!! cheers!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=61fbe11af907" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LifeCycle Methods of React Before 16.3 and after 16.3+?]]></title>
            <link>https://medium.com/@reddyeshashidhar/lifecycle-methods-of-react-before-16-3-and-after-16-3-32df3954dc75?source=rss-86665ccbadd2------2</link>
            <guid isPermaLink="false">https://medium.com/p/32df3954dc75</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[reactjs]]></category>
            <dc:creator><![CDATA[Shashidhar Reddy]]></dc:creator>
            <pubDate>Fri, 12 Jul 2019 11:35:58 GMT</pubDate>
            <atom:updated>2019-07-12T11:41:54.903Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/355/1*DmvQhohS99H9xxcxqiMbaQ.png" /></figure><p>React components have several “lifecycle methods” that allow us to execute various actions and process at particular times. These life cycles are important for one to work on React.</p><h3>The Lifecycle of a React Component</h3><p>The Lifecycle comes into picture in three phases. They are</p><p>Mounting</p><p>Updating</p><p>UnMounting</p><h3>Mount</h3><p>In my words,Mounting is nothing but adding nodes to the DOM.</p><p><strong>Mounting</strong> is the process of outputting the virtual representation of a component into the final UI representation (e.g. DOM or Native Components). — <strong>When searched in google</strong></p><ul><li>constructor()</li><li>componentWillMount()</li><li>render()</li><li>componentDidMount()</li></ul><h3>Update</h3><p>In my words,Updating means making changes to nodes already in the DOM</p><p>Update is nothing but any change in the component data i.e. either state change or props change. So, if any of the state or prop is changed, we have to immediately perform an update in the component.That means we have to re-render the component. For that we will be using these lifecycle methods.</p><ul><li>componentWillReceiveProps()</li><li>shouldComponentUpdate()</li><li>componentWillUpdate()</li><li>render()</li><li>componentDidUpdate()</li></ul><h3>Unmount</h3><p>Opposite to mounting, removing nodes from the DOM Unmounting.</p><ul><li>componentWillUnmount</li></ul><h3>Lifecycle Methods</h3><p>I will explain about the lifecycle methods with proper definition.</p><h3><strong>Before 16.3</strong></h3><h3>componentWillMount()</h3><pre>componentWillMount()</pre><p>componentWillMount is called before the<em> render()</em> method.</p><p>This is also used for App level configuration in your parent component.</p><p>The only lifecycle method that is called on the server side, when you use server-side rendering.</p><h3>componentDidMount</h3><pre>componentDidMount()</pre><p>Executed after first rendering of the component.Any changes in state or DOM updates and AJAX requests and set up event listeners should occur here.</p><h3>componentWillReceiveProps</h3><pre>componentWillReceiveProps(nextProps)</pre><p>When any particular prop updates then this method will be executed to trigger state transitions.</p><h3>shouldComponentUpdate</h3><pre>shouldComponentUpdate(nextState, nextProps)</pre><p>It will decide and tell whether the component needs to be updated or not.By default it will return true. If we don’t want the component to render after the state or props are updated, you can return false.</p><p>This is the place which allows you to prevent the re-render after receiving new prop.</p><h3>componentWillUpdate</h3><pre>componentWillUpdate(nextProps, nextState)</pre><p>Executed before re-rendering the component when there are props &amp; state changes confirmed by the ShouldComponentUpdate() which returns true.</p><h3>componentDidUpdate</h3><pre>componentDidUpdate(prevProps, prevState)</pre><p>Finally, we have to update the DOM in response to prop or state changes. This method will take care of it.</p><h3>componentWillUnmount</h3><pre>componentWillUnmount()</pre><p>Before React unmounts and destroys our component, it invokes <em>componentWillUnmount</em>.</p><p>To cancel any outgoing network requests, or removing any event listeners associated with the component etc.,</p><h3><strong>React 16.3+</strong></h3><h3>LifeCycle Methods:</h3><ul><li>getDerivedStateFromProps()</li><li>componentDidMount()</li><li>shouldComponentUpdate()</li><li>getSnapshotBeforeUpdate()</li><li>componentDidUpdate()</li><li>componentWillUnmount()</li></ul><h3>getDerivedStateFromProps</h3><p>It will be invoked before calling render() method same like componentWillMount() and it is also invoked on every render also. I heard this will be used for where we need derived state.</p><p>Read about derived state.</p><h3>getSnapshotBeforeUpdate</h3><p>Executed right before the rendered output is committed to the DOM.Any value that is returned by this will be passed to the <strong>componentDidUpdate().</strong></p><p>Main Usage: This is useful to capture the DOM information. i.e. scroll position etc.,</p><h3>componentDidMount</h3><h3>shouldComponentUpdate</h3><h3>componentDidUpdate</h3><h3>componentWillUnmount</h3><p>these are same as React 16.3 Before</p><p>Thanks for Reading… Took some information back from some sources that i read long back.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=32df3954dc75" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>