<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Abhiram Reddy</title>
    <description>The latest articles on DEV Community by Abhiram Reddy (@nrabhiram).</description>
    <link>https://dev.to/nrabhiram</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F420687%2Fab59ee26-8f2b-453c-bb93-24c8a2686149.jpeg</url>
      <title>DEV Community: Abhiram Reddy</title>
      <link>https://dev.to/nrabhiram</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nrabhiram"/>
    <language>en</language>
    <item>
      <title>React-Redux</title>
      <dc:creator>Abhiram Reddy</dc:creator>
      <pubDate>Sun, 05 Jul 2020 12:46:20 +0000</pubDate>
      <link>https://dev.to/nrabhiram/react-redux-1622</link>
      <guid>https://dev.to/nrabhiram/react-redux-1622</guid>
      <description>&lt;h1&gt;
  
  
  What is Redux?
&lt;/h1&gt;

&lt;p&gt;Simply put, Redux is a layer on top of React which helps in state management. Redux is mainly used in applications which rely on using class-based components. Redux has two tasks and they are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;creating a central data store for all the data in the application&lt;/li&gt;
&lt;li&gt;providing access to the data for all the components.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Redux makes state management really easy. Let me illustrate with an example. Let's say that we have two components nested in different parent components. However, they need access to the same data. This would be a cumbersome process if you do it the conventional way. And that is to pass down props to the various components until it trickles down all the way to the ones that require it.&lt;/p&gt;

&lt;h1&gt;
  
  
  How Does Redux Work?
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--O6GQu4yh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dab1nmslvvntp.cloudfront.net/wp-content/uploads/2017/09/150602352001-redux-flow-chart.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--O6GQu4yh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dab1nmslvvntp.cloudfront.net/wp-content/uploads/2017/09/150602352001-redux-flow-chart.png" alt=""&gt;&lt;/a&gt; &lt;br&gt;
Redux works in 4 simple steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A Redux store needs to be created where we store all the data (just as the name suggests).
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--j_AGAnXk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://seatoskylogistics.com/wp-content/uploads/2019/02/WH-02-Warehouse.gif" alt=""&gt;
&lt;/li&gt;
&lt;li&gt;Components subscribe to the data in the store so that it can be used by them.&lt;/li&gt;
&lt;li&gt;Whenever we want to update the state, we need to dispatch an action.
Ex. You want to delete a list item when you click on it. So, in the callback function which deals with the onClick event, we dispatch an action to the reducer, which is like the manager of the store. Only the reducer has access to the store. We can also pass additional data along with the action.&lt;/li&gt;
&lt;li&gt;Based on the type of the action, the reducer carries out different assignments. Continuing with the previous example, if the action type was 'DELETE_ITEM', the reducer is told what to do to deal with this action. And in our case, it would be to delete a specific item from an array structure (probably based on its ID).&lt;/li&gt;
&lt;li&gt;Now, once the action is carried out, the store is swiftly updated. And in turn, the components which subscribed to the data which also get updated.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now, let's see how we can use Redux in an actual application.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Use Redux
&lt;/h2&gt;

&lt;p&gt;Firstly, we will need to install 2 npm packages. And they are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;redux (to create store)&lt;/li&gt;
&lt;li&gt;react-redux (to connect the store with the application)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Then, we will create the store in the index.js file. This is because index.js is the file that starts the application.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BzmIBUgZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/gce62fgwm9gxy952e2bh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BzmIBUgZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/gce62fgwm9gxy952e2bh.png" alt=""&gt;&lt;/a&gt;&lt;br&gt;
We pass the rootReducer (the main reducer) as an argument when we are creating the store. This is to specify that this reducer is the one that has access to the store.&lt;/p&gt;

&lt;p&gt;In a component, to connect to the store, we need to import a function called connect. Connect, on being invoked, returns a higher order component (HOC) which we wrap around the component. We pass a function, mapStateToProps, in which we specify the data form the store that we want to subscribe to.&lt;br&gt;
We can also pass a second function which we use to dispatch an action and is called mapDispatchToProps. A method is added to the props of the components and is called whenever a certain DOM event is triggered. Then, the action gets dispatched and passed into the reducer.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jWZxL6nu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/pz6283a9712pm6phej03.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jWZxL6nu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/pz6283a9712pm6phej03.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Initially the state is empty. So, we must define an initial state in the reducer. In the reducer, we must write conditions for what must occur when an action of a specific type is dispatched.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--EKbGPU_c--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/lgona4dg4ndvo36icjf7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--EKbGPU_c--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/lgona4dg4ndvo36icjf7.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Thanks for Reading!
&lt;/h3&gt;

&lt;p&gt;And that's it! Redux is a topic that many developers struggle to grasp. But, once you get the hang of it, you realize what a great tool it is.&lt;br&gt;
If there's anything you would like to discuss, you can contact me on any one of my social handles. I would love to hear from you!&lt;br&gt;
Twitter: &lt;a href="https://twitter.com/nrabhiram"&gt;@nrabhiram&lt;/a&gt;&lt;br&gt;
LinkedIn: &lt;a href="https://www.linkedin.com/in/abhiram-reddy-23285b196/"&gt;Abhiram Reddy&lt;/a&gt;&lt;br&gt;
Instagram: &lt;a href="https://www.instagram.com/nr_abhiram/"&gt;@nr_abhiram&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Why is React so Popular?</title>
      <dc:creator>Abhiram Reddy</dc:creator>
      <pubDate>Sun, 05 Jul 2020 11:33:37 +0000</pubDate>
      <link>https://dev.to/nrabhiram/why-is-react-so-popular-1oa1</link>
      <guid>https://dev.to/nrabhiram/why-is-react-so-popular-1oa1</guid>
      <description>&lt;h1&gt;
  
  
  What is React?
&lt;/h1&gt;

&lt;p&gt;First of all, what is React? We've all probably heard of it at least once if we've been in touch with the tech industry (either that or you've been living under a rock) but what does it do? This question has bothered me for quite some time and I feel that now, I understand its popularity a little. I thought it would be cool to share my take on this with others, so here goes!&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YEp0UA-x--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://i.imgur.com/KfSxsDh.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YEp0UA-x--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://i.imgur.com/KfSxsDh.gif" alt=""&gt;&lt;/a&gt;&lt;br&gt;
React is a Javascript framework created by Facebook and a community of developers. And like any other framework, its purpose is to allow the developer to accomplish more by removing the tedious parts of coding. This in turn, allows one to accomplish more tasks with lesser lines of code. Pretty cool, I know. &lt;br&gt;
But the main reason why I feel that React is extremely popular is because of the large and supportive community it has amassed.&lt;/p&gt;

&lt;h1&gt;
  
  
  My Favorite React Features
&lt;/h1&gt;

&lt;p&gt;Here are 3 of the things that I found really useful in React:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Single Page Applications (SPA's)&lt;/li&gt;
&lt;li&gt;React-Router&lt;/li&gt;
&lt;li&gt;State Management&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Single Page Applications
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XjuS_xdd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://gearheart.io/media/images/SPA-1-768x454.original.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XjuS_xdd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://gearheart.io/media/images/SPA-1-768x454.original.png" alt=""&gt;&lt;/a&gt;&lt;br&gt;
Before the advent of SPA's, Multiple Page Applications (MPA's) were widely used. Let's first see how MPA's work so that we can understand how useful SPA's are.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do MPA's Work?
&lt;/h3&gt;

&lt;p&gt;In MPA's, if you want to go to another page, a request is first sent to the server. Then, the server responds by providing the required page.&lt;br&gt;
For example, let's say you go to a website. Now, you want to check the contact page. So, you click on the link in the navigation bar. When this occurs, a request is sent to the server that the user wants to see the contact page. So, the server sends the required page back to the user, which in our case will probably be contact.html. &lt;/p&gt;

&lt;h3&gt;
  
  
  How do SPA's Work?
&lt;/h3&gt;

&lt;p&gt;In SPA's, there is only one page, i.e, index.html. When you want to go to another page, the server provides the same page but with a different component injected into it. &lt;/p&gt;

&lt;h2&gt;
  
  
  React-Router
&lt;/h2&gt;

&lt;p&gt;But, the server provides the same page for every request. So, it doesn't make sense to send a request every time to the server. That is why we use the React Router. The router intercepts the request and sends the required component in response. This also prevents the page from reloading every time you go to a new page. &lt;/p&gt;

&lt;h2&gt;
  
  
  State Management
&lt;/h2&gt;

&lt;p&gt;In React, Components are either one of two types:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Class-Based Components&lt;/li&gt;
&lt;li&gt;Functional Components&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A component can share the data it contains with other components by adding them as properties to the props object.&lt;br&gt;
This becomes tedious when you are dealing with a large application. So there are tools like Redux which make state management a lot easier.&lt;br&gt;
However, recently, a new concept of Context API and hooks has been introduced and it is an even more convenient way to manage the state. I'll try covering both these concepts in one of my upcoming blog posts!&lt;/p&gt;

&lt;h2&gt;
  
  
  Thanks for Reading!
&lt;/h2&gt;

&lt;p&gt;Personally, I feel that React is a very easy framework to pick up. There's also a huge demand for React developers so I think that you should definitely give it a shot!&lt;br&gt;
I hope that I've been able to provide you with a clearer picture of why React is so widely used. If you have anything to discuss or would like to leave a suggestion, you can contact me on any one of my social handles. I would love to hear from you!&lt;/p&gt;

&lt;p&gt;Twitter: &lt;a href="https://twitter.com/nrabhiram"&gt;@nrabhiram&lt;/a&gt;&lt;br&gt;
LinkedIn: &lt;a href="https://www.linkedin.com/in/abhiram-reddy-23285b196/"&gt;Abhiram Reddy&lt;/a&gt;&lt;br&gt;
Instagram: &lt;a href="https://www.instagram.com/nr_abhiram/"&gt;@nr_abhiram&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Imports &amp; Exports</title>
      <dc:creator>Abhiram Reddy</dc:creator>
      <pubDate>Tue, 30 Jun 2020 16:16:15 +0000</pubDate>
      <link>https://dev.to/nrabhiram/imports-exports-52fg</link>
      <guid>https://dev.to/nrabhiram/imports-exports-52fg</guid>
      <description>&lt;p&gt;ES6 has brought a lot of revolutionary changes to the way Javascript code is written in general. And the frequently used ones are namely:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;variable declarations, ie const and let instead of var&lt;/li&gt;
&lt;li&gt;arrow functions&lt;/li&gt;
&lt;li&gt;imports and exports
In this post, I'll be talking about imports and exports.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XuqcDQ78--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://www.reactiongifs.com/r/dywtn.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XuqcDQ78--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://www.reactiongifs.com/r/dywtn.gif" alt="what is it?"&gt;&lt;/a&gt;&lt;br&gt;
So, what are these exactly?&lt;br&gt;
Well, with the arrival of ES6 features, the best thing that happened was that were now able to write modular code. This means that we can structure our code and separate our concerns by writing pieces of code which accomplish a specific task in separate files.&lt;br&gt;
The problem that arises now is, how do we connect these pieces of code to make the application functional? We can import the required parts code to use in that file.&lt;/p&gt;

&lt;p&gt;There are two ways to export your code:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;default exports&lt;/li&gt;
&lt;li&gt;named exports&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Default exports
&lt;/h3&gt;

&lt;p&gt;If you have only one function that you would like to reuse in other parts of your code you use default exports as shown below.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cTjpXrmL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/sdar3kbzw9y49gp64zh5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cTjpXrmL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/sdar3kbzw9y49gp64zh5.png" alt="default exports"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Named exports
&lt;/h3&gt;

&lt;p&gt;Named exports are used when you have multiple functions that need to be reused. Here is an example.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZAnxVB01--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/dni9uftxa6cgt98g56qh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZAnxVB01--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/dni9uftxa6cgt98g56qh.png" alt="named exports"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Where is it used?
&lt;/h2&gt;

&lt;p&gt;And that's pretty much it. Cool right? &lt;br&gt;
Personally, I love this feature because it helps you when creating larger projects.&lt;br&gt;
For instance, let's say you want to incorporate the MVC(Model, View, Controller) architecture into your code. The MVC model basically seperates the various concerns and the Controller acts as the central piece because it interacts with both the Model and View. So importing the required functions becomes necessary.&lt;br&gt;
I really hope that you find this useful. Do let me know what you think! You can contact me at &lt;a href="https://twitter.com/nrabhiram"&gt;https://twitter.com/nrabhiram&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
