<?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 Emir AKAR on Medium]]></title>
        <description><![CDATA[Stories by Emir AKAR on Medium]]></description>
        <link>https://medium.com/@eaakar.55?source=rss-a5ba0a120c2------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*lZCLgwo1e2E348ZwHC9FMQ.jpeg</url>
            <title>Stories by Emir AKAR on Medium</title>
            <link>https://medium.com/@eaakar.55?source=rss-a5ba0a120c2------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 20:26:09 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@eaakar.55/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[JavaScript Generators vs. Functions: Unraveling the Differences]]></title>
            <link>https://medium.com/cstech/javascript-generators-vs-functions-unraveling-the-differences-bc4bc2d7091a?source=rss-a5ba0a120c2------2</link>
            <guid isPermaLink="false">https://medium.com/p/bc4bc2d7091a</guid>
            <category><![CDATA[iteration]]></category>
            <category><![CDATA[functions-in-javascript]]></category>
            <category><![CDATA[javascript-generators]]></category>
            <category><![CDATA[asynchronous-programming]]></category>
            <dc:creator><![CDATA[Emir AKAR]]></dc:creator>
            <pubDate>Fri, 27 Oct 2023 08:22:28 GMT</pubDate>
            <atom:updated>2023-10-27T08:22:28.340Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mZieJ3eokbPCTuLO4KvMGQ.png" /><figcaption>Generators and Functions</figcaption></figure><p>JavaScript is a versatile and dynamic programming language that offers a variety of tools and features to developers. Two essential concepts for controlling the flow of execution in JavaScript are regular functions and generators. In this article, we will explore the differences between these two and when to use each, shedding light on their unique capabilities and use cases.</p><h3>Functions: The Building Blocks</h3><p>Functions are the fundamental building blocks of any JavaScript application. They are reusable blocks of code that can take parameters, perform actions, and return values. Functions can be defined using the function keyword or as arrow functions introduced in ECMAScript 6 (ES6).</p><p>Here’s a simple example of a regular function:</p><pre>function add(a, b) {<br>  return a + b;<br>}</pre><h3>Generators: A New Dimension</h3><p>Generators are also added to JavaScript, introduced with ES6. They provide a way to pause and resume the execution of a function, offering a unique mechanism for handling asynchronous tasks and complex data streams.</p><p>A generator function is defined using an asterisk (*) after the function keyword and uses the yield statement to pause its execution and yield a value.</p><p>Here&#39;s a simple generator function:</p><pre>function* count() {<br>  yield 1;<br>  yield 2;<br>  yield 3;<br>}</pre><h3>Key Differences</h3><h4>Execution Control:</h4><ul><li>Regular functions run to completion, executing all statements in one go.</li><li>Generator functions can pause their execution with the yield keyword and later resume from where they left off, allowing for cooperative multitasking.</li></ul><h4>Iterations:</h4><p>One of the powerful features of generators is their natural compatibility with iteration. You can use generators to create custom iterators for data structures or data streams.</p><p>Here’s an example of an iterable object using a generator:</p><pre>function* fibonacciSequence() {<br>  let a = 0, b = 1;<br>  while (true) {<br>    yield a;<br>    [a, b] = [b, a + b];<br>  }<br>}<br><br>const fibonacciIterator = fibonacciSequence();<br><br>// Let&#39;s print the first 10 Fibonacci numbers<br>for (let i = 0; i &lt; 10; i++) {<br>  console.log(fibonacciIterator.next().value);<br>}</pre><p>In this example, fibonacciSequence is a generator function that generates an infinite Fibonacci sequence. It uses destructuring to swap the values of a and b to calculate the next Fibonacci number. The generator is used to create an iterator, and the for loop retrieves the first 10 Fibonacci numbers. The generator naturally handles an infinite sequence, allowing you to extract values on-the-fly.</p><h4>Async Operations:</h4><p>Generators are especially helpful in managing asynchronous operations. They simplify asynchronous code by providing a more linear and readable structure. Here’s an example of using a generator to handle asynchronous operations, such as making multiple API requests:</p><pre>function* fetchMultipleAPIs() {<br>  try {<br>    const result1 = yield fetch(&#39;https://api.com/endpoint1&#39;);<br>    const data1 = yield result1.json();<br><br>    const result2 = yield fetch(&#39;https://api.com/endpoint2&#39;);<br>    const data2 = yield result2.json();<br><br>    console.log(data1, data2);<br>  } catch (error) {<br>    console.error(&#39;Error:&#39;, error);<br>  }<br>}<br><br>// Using a helper function to run the generator<br>function run(generator) {<br>  const iterator = generator();<br><br>  function iterate(iteration) {<br>    if (iteration.done) {<br>      return iteration.value;<br>    }<br><br>    const promise = iteration.value;<br><br>    return promise<br>      .then((x) =&gt; iterate(iterator.next(x)))<br>      .catch((x) =&gt; iterate(iterator.throw(x)));<br>  }<br><br>  return iterate(iterator.next());<br>}<br><br>run(fetchMultipleAPIs);</pre><p>In this example, fetchMultipleAPIs is a generator that fetches data from two different endpoints and logs the results. The run function is a utility to manage the generator&#39;s execution, handling both successful and error scenarios.</p><h3>When to Use Which Type of Function</h3><ol><li>Use regular functions for synchronous tasks, simple calculations, and logic that doesn’t require asynchronous behavior.</li><li>Use generators when you need to handle complex asynchronous operations, work with data streams, or manage long-running tasks. Generators simplify asynchronous code by making it more readable and maintainable.</li><li>Consider a combination of both in your codebase. Regular functions handle your core business logic, while generators manage the complex, asynchronous parts of your application.</li></ol><h3>Keep in Mind</h3><p>For the best practices, it’s good to keep in mind that every feature has its own pros and cons. For that reasons, you should consider about the cons such as;</p><ol><li><strong>Potential Memory Issues:</strong> Generators can hold the state and local variables in memory between `yield` points. If not managed properly, this can lead to memory leaks, especially in long-running generators.</li><li><strong>Debugging Challenges:</strong> Debugging generator functions can be more challenging, as they don’t execute linearly like regular functions, making it harder to trace the flow of code.</li></ol><h3>Conclusion</h3><p>JavaScript functions and generators are both essential tools in a developer’s toolkit, each with its unique strengths and use cases. Regular functions are suitable for most of your synchronous needs, while generators shine when dealing with asynchronous operations, data streams, and even infinite sequences. By understanding the differences and choosing the right tool for the job, you can write more efficient and maintainable JavaScript code.</p><h4><strong>References &amp; Resources:</strong></h4><ul><li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator">Generator - JavaScript | MDN</a></li><li><a href="https://www.geeksforgeeks.org/javascript-function-generator/">JavaScript Function Generator - GeeksforGeeks</a></li><li><a href="https://www.w3docs.com/learn-javascript/generators.html">JavaScript Generators - Learn JavaScript | W3Docs Tutorial</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bc4bc2d7091a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cstech/javascript-generators-vs-functions-unraveling-the-differences-bc4bc2d7091a">JavaScript Generators vs. Functions: Unraveling the Differences</a> was originally published in <a href="https://medium.com/cstech">ÇSTech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React useState Hook vs. Solid createSignals Hook]]></title>
            <link>https://medium.com/cstech/react-usestate-hook-vs-solid-createsignals-hook-f5cccb813d8c?source=rss-a5ba0a120c2------2</link>
            <guid isPermaLink="false">https://medium.com/p/f5cccb813d8c</guid>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[solidjs]]></category>
            <category><![CDATA[hooks]]></category>
            <category><![CDATA[state-management]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Emir AKAR]]></dc:creator>
            <pubDate>Tue, 04 Jul 2023 08:33:58 GMT</pubDate>
            <atom:updated>2023-07-04T08:33:58.670Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/925/1*zcRfKwFHo38-2hR0TUz_mA.png" /></figure><p>In the world of modern web development, building interactive user interfaces is a core aspect. JavaScript frameworks and libraries offer various tools to simplify the process, and React has been a popular choice due to its component-based architecture. React provides hooks, which are functions that allow developers to add stateful logic to functional components. One of the most widely used hooks is useState. However, a relatively new framework called Solid introduces a different approach with its createSignals hook. In this article, we will compare React’s useState hook with Solid’s createSignals hook, exploring their similarities, differences, and use cases.</p><p><strong>React’s useState Hook:</strong></p><p>React’s useState hook is a fundamental tool for enabling state management within functional components, offering a declarative approach that facilitates tracking and handling of component state changes. By utilizing useState, developers can declare and update state variables directly within their components, with the function returning a tuple comprising the current state value and an update function. Consequently, React automatically re-renders the component whenever the state changes, ensuring a reactive user interface. This aligns with React’s adoption of unidirectional data flow, wherein data flows from parent components to child components. Through this paradigm, the parent component takes responsibility for managing the state and transmits it to child components as props, enabling the child components to update the state by invoking the provided update function.</p><p>Let’s understand how react useState work with an example;</p><figure><img alt="Unidirectional Data Flow With React UseStates" src="https://cdn-images-1.medium.com/max/980/1*SXVbrVTey9pZa_9piKzogQ.png" /><figcaption>Unidirectional Data Flow With React UseStates</figcaption></figure><pre>import { FC, useState } from &quot;react&quot;;<br>import { ChildOne } from &quot;./components/child-one&quot;;<br>import { ChildTwo } from &quot;./components/child-two&quot;;<br>import { ChildThree } from &quot;./components/child-three&quot;;<br><br>import &quot;./App.css&quot;;<br><br>const App: FC = () =&gt; {<br>  const [counter, setCounter] = useState(0);<br><br>  const handleCounter = () =&gt; {<br>    setCounter(counter + 1);<br>    console.log(&quot;Clicked! (React)&quot;, counter + 1);<br>  };<br><br>  return (<br>    &lt;div className=&quot;App&quot;&gt;<br>      &lt;button onClick={handleCounter}&gt;Parent&lt;/button&gt;<br>      &lt;div&gt;<br>        &lt;ChildOne /&gt;<br>        &lt;ChildTwo /&gt;<br>        &lt;ChildThree counter={counter} /&gt;<br>      &lt;/div&gt;<br>    &lt;/div&gt;<br>  );<br>};<br><br>export default App;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/393/1*t9nLYs0MA8DCkyFF6N53lg.png" /><figcaption>Console Logs of React UseStates</figcaption></figure><p><strong>Solid’s createSignals Hook:</strong></p><p>Solid, a declarative and reactive JavaScript library, introduces the createSignals hook as an alternative to React’s useState. This hook is built on the concept of signals, which are observable values that can hold both synchronous and asynchronous data. By subscribing to signals, components in Solid automatically re-render whenever the subscribed signals change. This reactive data flow model enables fine-grained reactivity without the need for explicit instructions on how or when to update, reducing the explicit data passing between components. Solid’s createSignals hook and its reactive data flow paradigm provide developers with greater flexibility and efficiency in state management.</p><p>Let’s understand how solid createSignals work with an example;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/652/1*25uLyiBaBqw8Et3KLALp1Q.png" /><figcaption>Reactive Data Flow With Solid CreateSignals</figcaption></figure><pre>import { createSignal, type Component } from &quot;solid-js&quot;;<br>import { ChildOne } from &quot;./components/child-one&quot;;<br>import { ChildTwo } from &quot;./components/child-two&quot;;<br>import { ChildThree } from &quot;./components/child-three&quot;;<br><br>import &quot;./App.css&quot;;<br><br>const App: Component = () =&gt; {<br>  const [counter, setCounter] = createSignal(0);<br><br>  const handleCounter = () =&gt; {<br>    setCounter(counter() + 1);<br>    console.log(&quot;Clicked! (Solid)&quot;, counter());<br>  };<br>  <br>  return (<br>    &lt;div class=&quot;App&quot;&gt;<br>      &lt;button onClick={handleCounter}&gt;Parent&lt;/button&gt;<br>      &lt;div&gt;<br>        &lt;ChildOne /&gt;<br>        &lt;ChildTwo /&gt;<br>        &lt;ChildThree counter={counter()} /&gt;<br>      &lt;/div&gt;<br>    &lt;/div&gt;<br>  );<br>};<br><br>export default App;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/386/1*Jk0XRnf2PVRg0MD1Ev97ag.png" /><figcaption>Console Logs of Solid CreateSignals</figcaption></figure><p><strong>Similarities:</strong></p><p>Both React’s useState and Solid’s createSignals hooks share the goal of managing state within functional components. They provide a mechanism for storing and updating values that trigger re-renders. This similarity enables developers to build interactive and responsive user interfaces in both frameworks. Both hooks also follow a declarative approach, emphasizing the separation of concerns and making the code easier to reason about.</p><p><strong>Differences:</strong></p><ol><li>React’s useState hook is based on direct variable assignment, while Solid’s useSignals hook operates with signals that hold values. React’s approach may be more familiar to developers already experienced with JavaScript, while Solid’s signals introduce a new paradigm.</li><li>Solid’s createSignals hook offers more granular reactivity compared to React’s useState. With signals, developers can create fine-grained dependencies, ensuring that components only update when relevant signals change. This level of reactivity can improve performance and prevent unnecessary re-renders.</li></ol><p><strong>Use Cases:</strong></p><p>React’s useState hook is well-suited for most use cases, especially when building small to medium-sized applications with straightforward state management requirements. It&#39;s simplicity and wide adoption make it an excellent choice for many developers.</p><p>Solid’s createSignals hook shines in scenarios where fine-grained reactivity and more complex state management are essential. Applications with extensive data flows, asynchronous operations, or a need for high performance can benefit from Solid’s signals-based approach. It offers a reactive programming model that can handle intricate data dependencies efficiently.</p><p><strong>Conclusion:</strong></p><p>Both React’s useState hook and Solid’s useSignals hook serve as powerful state management tools for functional components. React’s useState provides a straightforward and widely adopted approach, while Solid’s createSignals introduces a more granular and reactive paradigm. The choice between the two ultimately depends on the specific requirements of your project. React remains a popular choice for its simplicity and extensive ecosystem, while Solid offers advanced reactivity and flexibility for complex applications. Exploring and understanding the strengths of each hook will help developers make informed decisions when building interactive user interfaces.</p><p><strong>References &amp; Resources:</strong></p><ul><li><a href="https://www.solidjs.com/docs/latest#createsignal">SolidJS</a></li><li><a href="https://react.dev/reference/react/useState">useState - React</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f5cccb813d8c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cstech/react-usestate-hook-vs-solid-createsignals-hook-f5cccb813d8c">React useState Hook vs. Solid createSignals Hook</a> was originally published in <a href="https://medium.com/cstech">ÇSTech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is React Custom Hooks and How to Use them in React Apps?]]></title>
            <link>https://medium.com/@eaakar.55/what-is-react-custom-hooks-and-how-to-use-them-in-react-apps-57edc2e1625c?source=rss-a5ba0a120c2------2</link>
            <guid isPermaLink="false">https://medium.com/p/57edc2e1625c</guid>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[react-hook]]></category>
            <dc:creator><![CDATA[Emir AKAR]]></dc:creator>
            <pubDate>Sat, 16 Apr 2022 16:34:10 GMT</pubDate>
            <atom:updated>2022-04-16T16:50:53.932Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qYPUVEhkYXnQ61-0" /><figcaption>Photo by <a href="https://unsplash.com/@vishu_2star?utm_source=medium&amp;utm_medium=referral">Vishal Jadhav</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In this article, we’re going to learn what is React Custom Hooks, how to build your own hooks, why you might need them, and how exactly you can create them. Therefore, throughout this article, we will be implementing a concrete example for this special topic.</p><p>Let’s get started!</p><h3><strong>What is a custom hook?</strong></h3><p>Firstly, we need to clarify what custom hooks are before we can dive into why we might need them.</p><p>Custom hooks are, in the end, just regular functions such as the built-in hooks, e.g., useState, but they are functions that can contain stateful logic. You can build custom hook functions to <strong>outsource</strong> stateful logic into <strong>reusable</strong> functions. <strong>Unlike regular functions, custom hooks can use other React hooks, including other custom hooks.</strong> In this way, you can use the React states with maximum efficiency.</p><p>This might be a bit abstract so, let’s dive into an example to understand how you can build custom hooks step by step.</p><h3><strong>1) Creating a Counter Application with and without Custom Hook</strong></h3><p>This is going to be a very simple but very useful example in terms of understanding the core basics of the custom hooks. Firstly, we will create this project without using custom hooks. After that, we will create the same project by using a custom hook which is going to be created by ourselves! In this way, you will be able to analyze what works best for you.</p><h4><strong>1.1) Building the counter project without Custom Hook</strong></h4><h4><strong>Step 1: First things first!</strong></h4><p>To be able to build a project, we need to create React JS. You can find the command that you need to use, right down below,</p><pre>npx create-react-app react-custom-hooks</pre><p>After the installation, you need to start the project. To be able to start your react project, you need to be in the file location that you created,</p><pre>cd react-custom-hooks</pre><p>After that, you can simply start the project,</p><pre>npm start</pre><h4><strong>Step 2: Let’s build our counter application components</strong></h4><p>In this project, there will be 2 counters. One of them will increase its value by 1 with one second time interval, and the other one will decrease its value by 1 with the same time interval. For those reasons, we need to create 2 components which are BackwardCounter.js and ForwardCounter.js.</p><h4><strong>Step 2.1: Building BackwardCounter.js</strong></h4><p>BackwardCounter.js will be the logic for decreasing the value of the counter by 1 with one second time interval,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/1*YIJrRbC9jOlxJVMheyCxAQ.png" /><figcaption>BackwardCounter.js</figcaption></figure><h4><strong>Step 2.2: Building ForwardCounter.js</strong></h4><p>ForwardCounter.js will be the logic for increasing the value of the counter by 1 with one second time interval,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/778/1*JSOhkDWBWNb9uyzEtMNYGA.png" /><figcaption>ForwardCounter.js</figcaption></figure><h4><strong>Step 2.3: Import the components into App.js</strong></h4><p>After creating the components, we need to import them into our App.js file,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/878/1*80r_4IpAxcXNfdOrJ_ZDJQ.png" /><figcaption>App.js</figcaption></figure><h4><strong>Step 2.4: The final look of our counter application</strong></h4><p>After all the creations, imports of the components, and adding a little bit of CSS, the application will look like this,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*pyC4zwVjkzBtA6ZeuWgZ7A.png" /><figcaption>Counter Project without Custom Hook</figcaption></figure><h4><strong>Step 3: Let’s analyze what we did so far!</strong></h4><p>As you can see from our components, we are actually using the same logic for both components with a small difference. The only difference is the state that we are using inside of the useEffect. The difference for the BackwardCounter.js is we are decreasing our setCounter by 1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/1*7N0QusMc6DVq00uuvxHRyg.png" /><figcaption>BackwardCounter.js</figcaption></figure><p>For the ForwardCounter.js, we are increasing our setCounter by 1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/683/1*eTZuj0LPDxLQO_PnHTF8xg.png" /><figcaption>ForwardCounter.js</figcaption></figure><p>In the end, they are working completely fine but as you can understand from the logic, we are <strong>repeating ourselves</strong> while building the counter application. <strong>One of the core logic of creating React applications is about writing the cleanest codes and not repeating yourself.</strong> For those reasons, we can simplify our counter logic and create a custom hook that can be used in any component without writing the same states many times by simply importing the custom hook inside of the components.</p><h4><strong>1.2) Building the counter application with Custom Hook</strong></h4><h4><strong>Step 1: Let’s create our Custom Hook!</strong></h4><p>Firstly, we can create a folder called hooks and then create a file called use-counter.js file. Names are totally up to you. The only thing that you should be careful about is that the function that you are going to create in this use-counter.js file should start with the “use” keyword just like useState, useEffect, etc. The rest of the function will be a regular function. <strong>Of course, there is no pressure to start with the “use” keyword but it is good to use the “use” keyword to continue with the general convention of the hooks.</strong></p><p>As it is can be seen from the figure right below, we used useState and useEffect hooks in our useCounter hook. Now, our useCounter hook can be used in any component by just simply importing it wherever you want to use it. This logic will be reusable in any component and the hook you are going to create can be used any time that you need to use them without writing the same code repeatedly. This is the true power of the Custom Hooks!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/1*2mEDgcdPBXFNY4CwGkrt6g.png" /><figcaption>use-counter.js</figcaption></figure><h4><strong>Step 2: Import the useCounter Hook inside of the ForwardCounter.js and BackwardCounter.js files</strong></h4><p>After creating the useCounter hook, now we can simplify our ForwardCounter.js and BackwardCounter.js files without duplicating our counter logic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*6SO3p_ob5pWOh8NUi8AKSw.png" /><figcaption>BackwardCounter.js</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/725/1*2tzEeP6M7-ZDaJB-vvDwPQ.png" /><figcaption>ForwardCounter.js</figcaption></figure><h4><strong>Step 2.1: The final look of our counter application</strong></h4><p>After creating our useCounter custom hook and importing it inside of the components, our application will look and run the same as before.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*RAobOcaAu1_cEoSM2vNyyA.png" /><figcaption>Counter Project with Custom Hook</figcaption></figure><h4><strong>Step 3: Let’s analyze what we did so far!</strong></h4><p>First, we created our custom hook called useCounter. After all the implementations, our counter project works smoothly and works with lesser code. Generally, it is important to keep components as less crowded as possible. Therefore, our custom hook provided us with a more suitable environment.</p><h4><strong>Let’s summarize what we did and what you learned from this article</strong></h4><p>We started this article by creating a Counter Application without using any custom hooks. After that, we created the same Counter Application via using a brand-new Custom Hook called useCounter that is created by us. Now, you can compare both approaches and see that the custom hook approach is more useful and more flexible than the other approach.</p><p>In most cases, if you are planning to create a project that contains one code piece which is used in many different components of your application, it is better to create custom hooks and import them where you want to use them. In this way, you can prevent yourself from making code duplications and your application’s performance can get much higher than you may ever think.</p><h4><strong>Side Notes:</strong></h4><p>There are lots of custom hooks in the wild that created by many people. If you want to see the most used Custom Hooks, you can check this <a href="https://medium.com/@sarat9/handy-custom-react-hooks-for-daily-use-302c0d236001">link </a>out.</p><p>Also, if you want to learn more about Custom Hooks, I strongly suggest you check the React Documents. You can find React Documents Custom Hooks via this <a href="https://reactjs.org/docs/hooks-custom.html">link</a>.</p><p><strong>Thanks for reading the article!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=57edc2e1625c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>