<?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: koushik chatterjee</title>
    <description>The latest articles on DEV Community by koushik chatterjee (@koushikweb).</description>
    <link>https://dev.to/koushikweb</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%2F616705%2Fbea166d3-1b9a-47da-9b8c-74c13538eb56.jpeg</url>
      <title>DEV Community: koushik chatterjee</title>
      <link>https://dev.to/koushikweb</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/koushikweb"/>
    <language>en</language>
    <item>
      <title>How to Use Different SSH Keys for GitHub and Bitbucket on the Same Machine</title>
      <dc:creator>koushik chatterjee</dc:creator>
      <pubDate>Sat, 29 Mar 2025 06:45:19 +0000</pubDate>
      <link>https://dev.to/koushikweb/how-to-use-different-ssh-keys-for-github-and-bitbucket-on-the-same-machine-hf</link>
      <guid>https://dev.to/koushikweb/how-to-use-different-ssh-keys-for-github-and-bitbucket-on-the-same-machine-hf</guid>
      <description>&lt;p&gt;When working on multiple projects that use different Git hosting services like GitHub and Bitbucket, we sometime need to configure separate SSH keys on the same machine. This step-by-step guide will show you how to set up multiple SSH keys on Ubuntu 22.04 for managing different Git accounts seamlessly. I have done this for ubuntu system but this approach is more or less for windows and mac os.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Check Existing SSH Keys&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Before generating new SSH keys, check if you already have any keys in your system:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ls -l ~/.ssh/&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Generate a New SSH Key for GitHub&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Since you already have an SSH key for Bitbucket, create a separate key for GitHub:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ssh-keygen -t rsa -b 4096 -C "your_email@example.com"&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;When prompted:&lt;/p&gt;

&lt;p&gt;Do not overwrite the existing key (id_rsa).&lt;/p&gt;

&lt;p&gt;Instead, save it as id_rsa_github (or another recognizable name).&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Enter file in which to save the key (/home/your-user/.ssh/id_rsa): /home/your-user/.ssh/id_rsa_github&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This will generate:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;~/.ssh/id_rsa_github (private key)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;~/.ssh/id_rsa_github.pub (public key)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Add Your New SSH Key to GitHub&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Copy your public key:
&lt;code&gt;cat ~/.ssh/id_rsa_github.pub&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Go to &lt;strong&gt;GitHub&lt;/strong&gt; → &lt;strong&gt;Settings&lt;/strong&gt; → &lt;strong&gt;SSH and GPG keys.&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Click "&lt;strong&gt;New SSH key&lt;/strong&gt;", paste the copied key, and save it.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Step 4: Configure SSH to Use the Correct Key&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To ensure Git uses the correct key for each service, configure SSH by editing (or creating) the&lt;/p&gt;

&lt;p&gt;&lt;code&gt;~/.ssh/config file:&lt;/code&gt;&lt;br&gt;
&lt;code&gt;nano ~/.ssh/config&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Add the following:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;# Bitbucket Configuration&lt;br&gt;
Host bitbucket.org&lt;br&gt;
  HostName bitbucket.org&lt;br&gt;
  User git&lt;br&gt;
  IdentityFile ~/.ssh/id_rsa&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;# GitHub Configuration&lt;br&gt;
  Host github.com&lt;br&gt;
  HostName github.com&lt;br&gt;
  User git&lt;br&gt;
  IdentityFile ~/.ssh/id_rsa_github&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Save and exit (&lt;code&gt;Ctrl + X&lt;/code&gt;, then &lt;code&gt;Y&lt;/code&gt; and &lt;code&gt;Enter&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5: Add SSH Keys to the SSH Agent&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To ensure the keys are loaded, start the SSH agent:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;eval "$(ssh-agent -s)"&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Save and exit (&lt;code&gt;Ctrl + X&lt;/code&gt;, then &lt;code&gt;Y&lt;/code&gt; and &lt;code&gt;Enter&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;Then add both keys:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ssh-add ~/.ssh/id_rsa&lt;br&gt;
ssh-add ~/.ssh/id_rsa_github&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 6: Test the SSH Connections&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Verify that SSH is correctly using each key:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ssh -T git@bitbucket.org&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Expected output:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;logged in as &amp;lt;your-bitbucket-username&amp;gt;.&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ssh -T git@github.com&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Expected output:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Hi &amp;lt;your-github-username&amp;gt;! You've successfully authenticated.&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Step 7: Clone Repositories Using the Correct SSH Key&lt;/p&gt;

&lt;p&gt;When cloning repositories, always use the correct SSH URL:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
For Bitbucket:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;git clone git@bitbucket.org:your-bitbucket-username/repository.git&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;For GitHub:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git clone git@github.com:your-github-username/repository.git&lt;/code&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Reactjs 19 - some key points to discuss</title>
      <dc:creator>koushik chatterjee</dc:creator>
      <pubDate>Fri, 01 Mar 2024 05:04:04 +0000</pubDate>
      <link>https://dev.to/koushikweb/reactjs-19-some-key-points-to-discuss-36k9</link>
      <guid>https://dev.to/koushikweb/reactjs-19-some-key-points-to-discuss-36k9</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0d5wvxd6ffb3t2zydhji.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0d5wvxd6ffb3t2zydhji.jpg" alt="Image description" width="800" height="457"&gt;&lt;/a&gt;&lt;br&gt;
No need to say that Reactjs is now one of the most demanding javascript library using and loved by most of the technology companies and so developers. As ReactJS 19 approaches its release, several exciting new features are expected to empower developers to create even more dynamic and efficient web applications. In this document, I am trying to explore some of the anticipated features of ReactJS 19.&lt;br&gt;
 &lt;strong&gt;1.Own Compiler :&lt;/strong&gt; In new react 19 we are going to get its own compiler which will compile and convert the react code into regular javascript code. This will make reactjs 2 times faster its execution and boost its power or rendering.&lt;br&gt;
&lt;strong&gt;2. Concurrent Rendering:&lt;/strong&gt; This new version of Reactjs will improve in concurrent rendering capabilities. Concurrent rendering allows React to work on multiple tasks simultaneously, making UI updates smoother and more responsive. This feature enhances the overall performance of React applications, especially for complex user interfaces with high interactivity.&lt;br&gt;
&lt;strong&gt;3. Improved Server-Side Rendering (SSR):&lt;/strong&gt; Server-Side Rendering is crucial for delivering fast initial page loads and improving SEO for web applications.Once major goal of ReactJS 19 is to enhance SSR capabilities further, optimising the rendering process on the server-side. This improvement will lead smooth running of application, make the application run faster and user will gain better experience when using this application.&lt;br&gt;
&lt;strong&gt;4. Suspense for Data Fetching:&lt;/strong&gt; Suspense is a powerful mechanism introduced in previous versions of React for handling asynchronous operations such as data fetching. The new React is expected to redefine and rescale the suspense mechanism and this will help developers in data fetching and doing asynchronous operations more effectively. &lt;br&gt;
&lt;strong&gt;5. Asset loading faster:&lt;/strong&gt; This is probably one of the best feature in new Reactjs where necessary assets like images or videos or files will load in background when user is doing some other important work in page. In that way it will minimize the loading time of webpage or reduce time to load an image.&lt;br&gt;
&lt;strong&gt;6. Built-in Error Boundaries:&lt;/strong&gt; Error boundaries enable developers to handle errors that occur during the rendering process, preventing the entire application from crashing. Expected that ReactJS 19 will introduce built-in error boundaries as a standard feature and helps developer to gain more flexibility in error handling and showing error page in more controlled ways.&lt;br&gt;
&lt;strong&gt;7. Improved DevTools Integration:&lt;/strong&gt; React Developer Tools is an essential to developers for debugging and profiling React applications during development. ReactJS 19 aims to enhance DevTools integration, providing developers with some more features and develop existing controls which will help developers to gain more power in debugging and measure application perforce as well.&lt;br&gt;
&lt;strong&gt;8. Context API over Redux :&lt;/strong&gt; State management is one challenge in React which we solve using Redux and context API. Normally redux we used to mange global state of an application and context api do the same job but not like react. But in this new Reactjs version it will be more powerful and can complete redux where in cases it might beat redux in global state management.&lt;/p&gt;

&lt;p&gt;Since ReactJs 19 still not introduced by React community officially so we can't validate these points now. But we hope that these above discussed points will make react more faster, robust, more poplular and more interesting from developers to IT companies.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>AI in Web Development: Revolutionizing the Digital Frontier</title>
      <dc:creator>koushik chatterjee</dc:creator>
      <pubDate>Mon, 19 Jun 2023 07:43:09 +0000</pubDate>
      <link>https://dev.to/koushikweb/ai-in-web-development-revolutionizing-the-digital-frontier-4dhe</link>
      <guid>https://dev.to/koushikweb/ai-in-web-development-revolutionizing-the-digital-frontier-4dhe</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ldbuzQQ0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ixec0g91prsw6eakj4g2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ldbuzQQ0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ixec0g91prsw6eakj4g2.png" alt="Image description" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Artificial Intelligence (AI) and Machine Learning (ML) have permeated various industries, and web development is no exception. The integration of AI and ML technologies has brought a myriad of possibilities, enabling developers to create intelligent, interactive, and personalized web experiences. Technology is exploring and new ideas and innovations are coming every day. Some of the very common hence super useful AI tools I am discussing here,&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Chatbots and Virtual Assistants:&lt;/strong&gt; AI-powered chatbots and virtual assistants have transformed customer support and engagement on websites. These intelligent bots use Natural Language Processing (NLP) algorithms to understand user queries and provide instant responses, 24/7. They can assist with tasks like answering common questions, guiding users through processes, and even performing transactions. By automating routine tasks, chatbots enhance user experiences, reduce response times, and improve customer satisfaction.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Content Generation and Personalization:&lt;/strong&gt; AI algorithms can analyze user behavior, preferences, and demographics to create personalized web content. By leveraging ML techniques, websites can tailor recommendations, product suggestions, and content offerings based on individual user interests. AI can also generate dynamic content by aggregating and curating relevant information from various sources, reducing manual content creation efforts while maintaining quality and relevancy.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Automated Testing and Bug Detection:&lt;/strong&gt; AI can automate the testing and debugging process in web development. ML models can learn from existing codebases to detect potential bugs, vulnerabilities, or performance issues. Min toltivation here is not only reduce the time but also envhance overall users expereience and quality in web development. AI-powered testing tools can simulate user interactions, identify edge cases, and generate test cases to ensure comprehensive test coverage and minimize human error.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Image and Video Processing:&lt;/strong&gt; AI algorithms can analyze and process images and videos on websites. Through computer vision techniques, ML models can automatically tag, classify, and describe visual content. This enables advanced image search functionalities, automated content moderation, and even augmented reality (AR) experiences. By harnessing AI's capabilities, web developers can create visually immersive and engaging user interfaces.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Natural Language Processing (NLP) and Sentiment Analysis:&lt;/strong&gt; NLP techniques allow web applications to understand and interpret human language. Sentiment analysis algorithms can analyze user feedback, comments, and reviews to extract sentiments and gauge public opinion. This information can be invaluable for businesses to understand customer satisfaction levels, identify potential issues, and make data-driven decisions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. User Experience Optimization:&lt;/strong&gt; AI can optimize web experiences by analyzing user interactions and feedback. ML models can learn from user behavior patterns to improve website navigation, layout, and content placement. AI-powered recommendation systems can suggest relevant content or products, reducing decision fatigue for users. By continuously adapting to user preferences, AI enhances user experiences and increases engagement and conversion rates.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;7. Cybersecurity and Fraud Detection:&lt;/strong&gt;  AI-based cybersecurity solutions can detect and prevent various web threats. ML algorithms can analyze network traffic, user behavior, and system logs to identify potential security breaches, phishing attempts, and fraud. AI can also bolster authentication mechanisms through biometric recognition or anomaly detection techniques, enhancing web application security.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion:&lt;/strong&gt; The integration of AI and ML technologies in web development has opened up a world of possibilities from the old monithic and legact form to hight tech intellegent form. From intelligent chatbots to personalized content generation, automated testing to image processing, and sentiment analysis to cybersecurity, AI revolutionizes the web development landscape. By harnessing these capabilities, developers can create intelligent, interactive, and user-centric web experiences, redefining the digital frontier.&lt;br&gt;
Regenerate response&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to install mongodb community edition to ubuntu 22.04</title>
      <dc:creator>koushik chatterjee</dc:creator>
      <pubDate>Fri, 27 Jan 2023 16:13:44 +0000</pubDate>
      <link>https://dev.to/koushikweb/how-to-install-mongodb-community-edition-to-ubuntu-2204-2ld3</link>
      <guid>https://dev.to/koushikweb/how-to-install-mongodb-community-edition-to-ubuntu-2204-2ld3</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--X3AH79qu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1g077rgkvkw18ejmsdhi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--X3AH79qu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1g077rgkvkw18ejmsdhi.png" alt="Image description" width="800" height="217"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.mongodb.com/"&gt;Mongodb&lt;/a&gt; is a widely used document oriented NoSQL database management system. Mongodb uses json like format called BSON ( Bianary Json) and it stores data in a collection of documents rather than storing in a table. Mongodb is designed in that way, it can be scaled and performed in an optional lavel and that became a choice for many large scale applications. &lt;br&gt;
    Mongodb is used in many web and mobile applications and here are the steps to install mongodb in ubuntu system 22.04,&lt;/p&gt;

&lt;p&gt;&lt;em&gt;step 1 :&lt;/em&gt; Import the MongoDB public GPG key:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt-get install gnupg
wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;step 2 :&lt;/em&gt; Create a file for mongoDB&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;step 3:&lt;/em&gt; Reload the package database&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt-get update
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Step 4:&lt;/em&gt; Install MongoDB Community Edition&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt-get install -y mongodb-org
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Step 5:&lt;/em&gt; Start mongoDB&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo systemctl start mongod
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;you can also enable automatic start of mongoDB on boot by using this command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo systemctl enable mongod
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Troubleshoot : While you are going to start mongoDB you might see this message,&lt;/p&gt;

&lt;p&gt;&lt;code&gt;MongoDB Install Fails on Ubuntu 22.04 - Depends on libssl1.1 but it is not installable&lt;/code&gt; as Ubuntu 22.04 has upgraded libssl to 3 and does not propose libssl1.1. as  MongoDb has no official build for ubuntu 22.04. To overcome this issue ubuntu 22.04 installed in your system need to force the installation of libssl1.1 by adding the ubuntu 20.04 source:&lt;/p&gt;

&lt;p&gt;step 1:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;echo "deb http://security.ubuntu.com/ubuntu focal-security main" | sudo tee /etc/apt/sources.list.d/focal-security.list
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Sep 2: Now again run the same previosly used command to install mongodb,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt-get install -y mongodb-org
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;now delete the focal-security list file you just created,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo rm /etc/apt/sources.list.d/focal-security.list
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you you can start mongoDB in your system using command,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo systemctl start mongod
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and it will start working fine in your sytem.&lt;/p&gt;

</description>
      <category>mongodb</category>
      <category>nosql</category>
      <category>webdev</category>
      <category>ubuntu</category>
    </item>
    <item>
      <title>ReactJs commonly used Hooks</title>
      <dc:creator>koushik chatterjee</dc:creator>
      <pubDate>Mon, 16 Jan 2023 13:04:59 +0000</pubDate>
      <link>https://dev.to/koushikweb/reactjs-commonly-used-hooks-4gbo</link>
      <guid>https://dev.to/koushikweb/reactjs-commonly-used-hooks-4gbo</guid>
      <description>&lt;p&gt;React Hooks are a way to use state and other React features in functional components, rather than in class components. They allow you to use state and other lifecycle methods in functional components, which can make your code more readable and easier to understand. Hooks are introduced from react 16.8. In a simple sentence we can say that by using hooks we can use both the state and lifecycle methods in a class component. So before introducing hooks developers had to use class components to get the advantage of lifecycle methods like &lt;code&gt;componentDidMount&lt;/code&gt;  or &lt;code&gt;componentDidUpdate&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;There are lots of benefits of using hooks in your react code. Implementing hooks in your code gives a cleaner look of your code. It looks simple and understandable to a person who is even new in react and it is made for functional component and so it is ok if you don’t have a good knowledge in OOPs.  By using hooks  you can write a better code by splitting a big component into smaller components. Even hooks perform faster than the same code written in class component.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Hooks are made to use in functional component. So it should call only in functional component&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Call hooks from react functional component and avoid to call from regular javascript functions.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Hooks should be called from top level only. That means you should avoid to call from inside a loop, nested if else of switch statements. So basically it ensures that the hooks call in the same order you have written whenever that components renders.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Hooks can be called from other hooks of any custom hooks&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;There are many hooks in react and some of them are &lt;/p&gt;

&lt;p&gt;Basic Hooks : useState, useEffect, useContext&lt;/p&gt;

&lt;p&gt;Additional Hooks: useReducer, useCallback, useMemo, useRef, useImperativeHandle, useLayoutEffect, useDebugValue&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;UseState :&lt;/strong&gt; When called, this hook returns a stateful value. Use state hook is used in functional components. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;import React, { useState } from 'react';&lt;br&gt;
 const [myVariable, setMyVariable] = useState(0);&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
Here setMyVaribale is a callback which will set the return value to myVariable.We set initial state as 0 by passing useState(0). In react class component we can do this using setStae() method.&lt;br&gt;
ref: &lt;a href="https://reactjs.org/docs/hooks-state.html"&gt;https://reactjs.org/docs/hooks-state.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;UseEffect : Use effect hook is used to perform side effect in reactjs functions. When we do some operations eg. fetch data from api, then useEffect hooks calls after dom render and it don't block browser.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0fcYZosP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4covgvds2ya2tn54ec1h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0fcYZosP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4covgvds2ya2tn54ec1h.png" alt="Image description" width="653" height="493"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;useContext : This hook allows you to access context in a functional component. It takes a context object as an argument and returns the current value of the context. For example, the following code sets up a context for a theme and uses it to set the background color of a component.  Context is used to pass down data from higher level component to lower level components without having pass props manually in each lavel. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OegtSYda--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6tnrkg6rdq3xlohofdsh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OegtSYda--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6tnrkg6rdq3xlohofdsh.png" alt="Image description" width="656" height="522"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;useCallback: This hook allows you to optimize the performance of your component by memoizing a callback. It takes a callback and an array of dependencies as arguments and returns a memoized callback that will only change if one of the dependencies has changed. This can be useful if you have a component that re-renders often and has a callback that is expensive to create.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0wPVCkmd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/63anll1so03aw4brsqaf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0wPVCkmd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/63anll1so03aw4brsqaf.png" alt="Image description" width="656" height="546"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;USeMemo :  A React hook that allows you to memoize a component's expensive calculations and return a cached result for performance optimization. It takes two arguments: the first is the calculation to be memoized, and the second is an array of dependencies that should trigger a recalculation.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FS6ajyjI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dlqmlu4xw1fn2skt97a1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FS6ajyjI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dlqmlu4xw1fn2skt97a1.png" alt="Image description" width="656" height="277"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;useRef : This hook in React allows to create a reference to a DOM element or a component instance. One can use this reference to access the element's properties and methods. Here is an example of using useRef to create a reference to a text input &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VH0MMYJq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ha4gu814ikiki72mihnx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VH0MMYJq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ha4gu814ikiki72mihnx.png" alt="Image description" width="662" height="412"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are many other hooks are available in reactjs. We discussed some of the commonly used hooks here . and These hooks helps to carry and maintain states inside a react component.&lt;/p&gt;

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