<?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: gokulmathew</title>
    <description>The latest articles on DEV Community by gokulmathew (@gokulmathew).</description>
    <link>https://dev.to/gokulmathew</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%2F397206%2F34a67bea-7015-4290-a6fb-9541b1c84939.jpeg</url>
      <title>DEV Community: gokulmathew</title>
      <link>https://dev.to/gokulmathew</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/gokulmathew"/>
    <language>en</language>
    <item>
      <title>React Hooks and its Advantages</title>
      <dc:creator>gokulmathew</dc:creator>
      <pubDate>Sun, 28 Jun 2020 17:58:44 +0000</pubDate>
      <link>https://dev.to/gokulmathew/react-hooks-and-its-advantages-23lf</link>
      <guid>https://dev.to/gokulmathew/react-hooks-and-its-advantages-23lf</guid>
      <description>&lt;p&gt;&lt;strong&gt;React Hooks :&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;React hooks&lt;/strong&gt; are functions that let you &lt;strong&gt;hook&lt;/strong&gt; into react state and life-cycle features from function components. React provides built-in hooks like useState, useEffect, useReducer, useRef, useCallback, useContext, useMemo and you can also create you own custom hooks.&lt;/p&gt;

&lt;p&gt;React hooks are available from react version of &lt;strong&gt;16.8&lt;/strong&gt;. Before the introduction of hooks, state can be maintained only in class component not in functional component, after the introduction of hooks, state can be maintained in &lt;strong&gt;functional component&lt;/strong&gt; also.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Advantages of react hooks over class component :&lt;/strong&gt;&lt;br&gt;
The main advantage of react hooks is the &lt;strong&gt;re-usability of stateful logic&lt;/strong&gt;. It can be done with the help of &lt;strong&gt;custom hooks&lt;/strong&gt;. Without changing component hierarchy, you can reuse stateful logic and it is easy to share custom hooks with other components.&lt;/p&gt;

&lt;p&gt;In react class component, we split our work in different life-cycle methods like componentDidMount, componentDidUpdate and componentWillUnmount, but in hooks, we can do everything in a single hook called &lt;strong&gt;useEffect&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In class component, we have to use &lt;strong&gt;this&lt;/strong&gt; keyword and also we have to &lt;strong&gt;bind event listeners&lt;/strong&gt;, which increases complexity. This is prevented in react functional components.&lt;/p&gt;

&lt;p&gt;React class components don’t minify very well, and they make hot reloading flaky and unreliable.&lt;/p&gt;

&lt;p&gt;React hooks are easier to &lt;strong&gt;test and work&lt;/strong&gt; with, makes the code look cleaner, easier to read and has less number of lines of code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;useState Hook :&lt;/strong&gt;&lt;br&gt;
useState hook is used to add state to a functional component.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ewaP7Fq0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/h2qidkizxjdh0ln9y9a8.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ewaP7Fq0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/h2qidkizxjdh0ln9y9a8.jpeg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the above snippet, the initial value of the blogName state variable is ‘React’. Using setBlogName setter function, you can change the value of the blogName state variable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;useEffect Hook :&lt;/strong&gt;&lt;br&gt;
In class component , when the document title has to be based on counter state value, and when the document title has to updated whenever the counter value changes, we use the following code.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--D-05l5rs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ujdjnfrrdnplveoya2by.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--D-05l5rs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ujdjnfrrdnplveoya2by.jpeg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the above code snippet, the codes inside componentDidMount and componentDidUpdate are relatable, but they are written in two different methods. To overcome this, we can use &lt;strong&gt;useEffect&lt;/strong&gt; hook.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KgNdv8b9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/t1wx60chgz5h9icl1feh.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KgNdv8b9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/t1wx60chgz5h9icl1feh.jpeg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The above useEffect hook gets executed after every component render and whenever the count changes, it will be executed again. You can have &lt;strong&gt;multiple useEffect hooks&lt;/strong&gt; in a single component, where you write relatable code inside each.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Custom Hooks :&lt;/strong&gt;&lt;br&gt;
Custom hooks is a easy way to &lt;strong&gt;re-use stateful logic&lt;/strong&gt; in react hooks.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gYfj5W5X--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/nzgp0gg8ml8g1bhkafwa.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gYfj5W5X--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/nzgp0gg8ml8g1bhkafwa.jpeg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The above snippet is an example of a custom form hook, it accepts the initial value as props and sends the initial value, setter function and reset function.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jogKd3v1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ljfzgayif8qg3thk5xme.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jogKd3v1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ljfzgayif8qg3thk5xme.jpeg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can import useInput custom hook in your component and you can use it in your component like this.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion :&lt;/strong&gt;&lt;br&gt;
React hooks don’t replace your knowledge of react concepts. Instead, hooks provide a more direct way to use react concepts which you already know.&lt;/p&gt;

&lt;p&gt;In future, &lt;strong&gt;hooks&lt;/strong&gt; will be mostly used, and will get &lt;strong&gt;good support&lt;/strong&gt; from react team.&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
    </item>
    <item>
      <title>What is React JS</title>
      <dc:creator>gokulmathew</dc:creator>
      <pubDate>Sun, 07 Jun 2020 11:12:05 +0000</pubDate>
      <link>https://dev.to/gokulmathew/what-is-react-js-50jg</link>
      <guid>https://dev.to/gokulmathew/what-is-react-js-50jg</guid>
      <description>&lt;p&gt;A Brief story behind React:&lt;br&gt;
React is a Java Script library developed by Facebook . It is used to create appealing UI and UX in websites and web applications.&lt;br&gt;
React helps you develop Single Page Applications, website or web application that dynamically rewrites the data in the web page with the new data it receives from the web server instead of reloading the entire web page.&lt;/p&gt;

&lt;p&gt;How React works ?&lt;br&gt;
Generally HTML code of a web page gets converted to Document Object Model (DOM), and it is rendered as a web page by the web browser.&lt;br&gt;
React creates a virtual DOM from the actual DOM at first, and displays it to us. Whenever a change is made in the actual DOM, React compares virtual DOM with the actual DOM. And, updates the change in the virtual DOM.&lt;br&gt;
React uses JSX to write HTML code. The JSX code will be transcompiled to Javascript before the browser renders.&lt;/p&gt;

&lt;p&gt;Why choose React?&lt;br&gt;
Uses Virtual DOM. So it renders very fast.&lt;br&gt;
Easy to learn, supports code re-usability.&lt;br&gt;
“Learn once, write anywhere library ”. React is the heart of React Native. React Native is a mobile application framework, and react native apps are supported by both iOS and Android.&lt;br&gt;
Not only SEO friendly, but also backed by a strong community, Facebook and Instagram development teams.&lt;/p&gt;

&lt;p&gt;Quick Summary&lt;br&gt;
The main idea behind React is to build large-scale SPA with data that changes repeatedly over time, and tackles the challenges.&lt;br&gt;
Provides developers with the capability of working with a virtual DOM, much faster and user-friendly. Also, offers easier creation of interactive UIs, JSX support, component-based structure and much more.&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
