<?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>Forem: Ishrat Jahan Esha</title>
    <description>The latest articles on Forem by Ishrat Jahan Esha (@ishrat_esha).</description>
    <link>https://forem.com/ishrat_esha</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%2F1409643%2Fd6364f09-6735-42cd-a3a0-6170ca8a2f21.jpg</url>
      <title>Forem: Ishrat Jahan Esha</title>
      <link>https://forem.com/ishrat_esha</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/ishrat_esha"/>
    <language>en</language>
    <item>
      <title>React Context APi</title>
      <dc:creator>Ishrat Jahan Esha</dc:creator>
      <pubDate>Thu, 29 Aug 2024 08:26:25 +0000</pubDate>
      <link>https://forem.com/ishrat_esha/react-context-api-oee</link>
      <guid>https://forem.com/ishrat_esha/react-context-api-oee</guid>
      <description>&lt;p&gt;The React Context API is a powerful feature that allows you to manage state and share data across your React application without passing props down through every level of the component tree. This is particularly useful for managing global state, like user authentication, theme settings, or a shopping cart, where data needs to be accessible by many components at different levels of the component hierarchy.&lt;/p&gt;

&lt;p&gt;Key Concepts of React Context API&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Context Object:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A context object is created using &lt;code&gt;React.createContext()&lt;/code&gt;. This object contains two components: a Provider and a Consumer.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;Provider&lt;/code&gt; component supplies the context to its child components.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;Consumer&lt;/code&gt; component allows components to access the context.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Provider:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;Provider&lt;/code&gt; component is a part of the context object. It wraps around the components that need access to the context data.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;Provider&lt;/code&gt; component accepts a &lt;code&gt;value&lt;/code&gt; prop, which represents the data you want to share with consuming components.&lt;/li&gt;
&lt;li&gt;All components within the &lt;code&gt;Provider&lt;/code&gt; can access the context data.
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;   &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;MyContext&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createContext&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

   &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;App&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* some state or data */&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
     &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
       &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;MyContext&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Provider&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
         &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;ChildComponent&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
       &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/MyContext.Provider&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;     &lt;span class="p"&gt;);&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Consumer:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;Consumer&lt;/code&gt; component is used to consume the context data. Any component wrapped in &lt;code&gt;Consumer&lt;/code&gt; will have access to the data provided by the nearest &lt;code&gt;Provider&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;Consumer&lt;/code&gt; component requires a function as its child, which receives the context value as its argument.
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;   &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;ChildComponent&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
       &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;MyContext&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Consumer&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
         &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="cm"&gt;/* render something based on the context value */&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
       &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/MyContext.Consumer&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;     &lt;span class="p"&gt;);&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;However, in modern React, the &lt;code&gt;useContext&lt;/code&gt; hook is more commonly used instead of the &lt;code&gt;Consumer&lt;/code&gt; component.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;useContext Hook:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;React introduced the &lt;code&gt;useContext&lt;/code&gt; hook in version 16.8, which simplifies consuming context by eliminating the need for the &lt;code&gt;Consumer&lt;/code&gt; component.&lt;/li&gt;
&lt;li&gt;You can use the &lt;code&gt;useContext&lt;/code&gt; hook to access the context directly within any functional component.
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;   &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useContext&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

   &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;ChildComponent&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useContext&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;MyContext&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
     &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
       &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
         &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="cm"&gt;/* render something based on the context value */&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
       &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;     &lt;span class="p"&gt;);&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  When to Use Context API
&lt;/h3&gt;

&lt;p&gt;The Context API is ideal when you have global data or functions that need to be accessed by multiple components at different levels of the component tree. Some common use cases include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Theming:&lt;/strong&gt; Sharing theme data (e.g., dark or light mode) across your app.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Authentication:&lt;/strong&gt; Managing and accessing user authentication status and data.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Language Settings:&lt;/strong&gt; Handling multilingual support across the app.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Shopping Cart:&lt;/strong&gt; Sharing the cart state in an e-commerce application.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Limitations and Considerations
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Overuse:&lt;/strong&gt; The Context API is powerful, but it can be overused. It’s best suited for truly global data. Overusing it can lead to tightly coupled components and make your app harder to manage.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Performance:&lt;/strong&gt; Since context updates can cause all consuming components to re-render, it’s essential to manage context updates efficiently to avoid unnecessary re-renders.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webdev</category>
      <category>react</category>
      <category>programming</category>
    </item>
    <item>
      <title>5 JavaScript conditional operators</title>
      <dc:creator>Ishrat Jahan Esha</dc:creator>
      <pubDate>Tue, 23 Apr 2024 09:07:18 +0000</pubDate>
      <link>https://forem.com/ishrat_esha/5-javascript-conditional-operators-8nn</link>
      <guid>https://forem.com/ishrat_esha/5-javascript-conditional-operators-8nn</guid>
      <description>&lt;p&gt;In JavaScript, conditional operators are used to make decisions based on certain conditions. The primary conditional operator in JavaScript is the &lt;strong&gt;if&lt;/strong&gt; statement, which allows you to execute a block of code if a specified condition is true. Additionally, JavaScript also provides other conditional operators like else, else if, switch, and the ternary operator (? :). Here's a brief overview of each:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;*&lt;em&gt;if *&lt;/em&gt;: &lt;br&gt;
if is a primary conditional operator in js.&lt;br&gt;
syntax&lt;br&gt;&lt;br&gt;
if (condition) {&lt;br&gt;
// Code to be executed if the condition is true&lt;br&gt;
}&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;else...if&lt;/strong&gt; : when two fact which can be execute in a function than comes the else if as a solution &lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;syntax &lt;br&gt;
 if (condition) {&lt;br&gt;
    // Code to be executed if the condition is true&lt;br&gt;
} else {&lt;br&gt;
    // Code to be executed if the condition is false&lt;br&gt;
}&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;if...else if...else Statement&lt;/strong&gt;: when there are more than two condition can be execute in a function then we used  if...else if...else Statement it used for complex conditional rendering. &lt;br&gt;
syntax &lt;br&gt;
if (condition1) {&lt;br&gt;
// Code to be executed if condition1 is true&lt;br&gt;
} else if (condition2) {&lt;br&gt;
// Code to be executed if condition2 is true&lt;br&gt;
} else {&lt;br&gt;
// Code to be executed if none of the conditions are true&lt;br&gt;
}&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Switch Statement&lt;/strong&gt;: switch statement is used in big or complicated conditional statement.&lt;br&gt;
syntax&lt;br&gt;
switch (expression) {&lt;br&gt;
case value1:&lt;br&gt;
    // Code to be executed if expression === value1&lt;br&gt;
    break;&lt;br&gt;
case value2:&lt;br&gt;
    // Code to be executed if expression === value2&lt;br&gt;
    break;&lt;br&gt;
default:&lt;br&gt;
    // Code to be executed if expression doesn't match any case&lt;br&gt;
}&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;5.&lt;strong&gt;Ternary Operator (Conditional Operator)&lt;/strong&gt;: &lt;br&gt;
Now a day it's most popular and easy Conditional operator that can solve a large statement with a single line of code .&lt;/p&gt;

&lt;p&gt;syntax :&lt;br&gt;
(condition) ? expression1 : expression2;&lt;br&gt;
// If the condition is true, expression1 is evaluated; otherwise, expression2 is evaluated.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>programming</category>
      <category>learning</category>
    </item>
    <item>
      <title>what is API ?</title>
      <dc:creator>Ishrat Jahan Esha</dc:creator>
      <pubDate>Tue, 23 Apr 2024 08:29:21 +0000</pubDate>
      <link>https://forem.com/ishrat_esha/what-is-api--32gn</link>
      <guid>https://forem.com/ishrat_esha/what-is-api--32gn</guid>
      <description>&lt;p&gt;&lt;strong&gt;API&lt;/strong&gt; stands for &lt;strong&gt;Application Programming Interface&lt;/strong&gt;. It's essentially a set of rules and protocols that allows different software applications to communicate with each other. APIs define the methods and data formats that developers can use to interact with a software component, service, or platform.&lt;/p&gt;

&lt;p&gt;Here are some key points about APIs:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Interoperability&lt;/strong&gt;: APIs enable different software systems to work together seamlessly, even if they are developed by different companies or individuals.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Abstraction&lt;/strong&gt;: APIs provide a layer of abstraction, allowing developers to interact with a system or service without needing to understand its internal workings.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Standardization&lt;/strong&gt;: APIs often follow standardized protocols and data formats, making it easier for developers to integrate with them.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Functionality&lt;/strong&gt;: APIs expose certain functionalities or services provided by a software component. For example, a weather API might provide methods for retrieving current weather data based on location.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Security&lt;/strong&gt;: APIs can include authentication and authorization mechanisms to ensure that only authorized users or applications can access certain functionalities or data.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Documentation&lt;/strong&gt;: Good APIs come with thorough documentation that explains how to use them, including details about available endpoints, request parameters, response formats, etc.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Overall, APIs play a crucial role in enabling software integration, facilitating the development of complex systems, and enabling innovation by allowing developers to build on top of existing services and functionalities.&lt;/p&gt;

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