<?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: Fyno</title>
    <description>The latest articles on DEV Community by Fyno (@fyno).</description>
    <link>https://dev.to/fyno</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%2Forganization%2Fprofile_image%2F7829%2Fec27614c-6fed-4d8a-82ce-ec5acd742ec0.png</url>
      <title>DEV Community: Fyno</title>
      <link>https://dev.to/fyno</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/fyno"/>
    <language>en</language>
    <item>
      <title>A simple guide to addressing single point of failure (SPOF) while evaluating external tools</title>
      <dc:creator>Rohit</dc:creator>
      <pubDate>Fri, 02 Feb 2024 08:01:56 +0000</pubDate>
      <link>https://dev.to/fyno/a-simple-guide-to-addressing-single-point-of-failure-spof-while-evaluating-external-tools-49k9</link>
      <guid>https://dev.to/fyno/a-simple-guide-to-addressing-single-point-of-failure-spof-while-evaluating-external-tools-49k9</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;Introduction:&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;In the dynamic landscape of technology, reliability is a key ingredient in the recipe for long term success, especially when evaluating external tools or Software as a Service (SaaS). This guide is your compass through the realm of Single Points of Failure (SPOF) as we navigate the intricacies of evaluating external tools.&lt;/p&gt;

&lt;p&gt;Understanding SPOF isn't merely about isolated considerations; it's an integral part of a broader assessment of reliability. This exploration goes beyond the surface, looking at factors that contribute to a robust and resilient tech ecosystem, with a focus on external tools and SaaS platforms.&lt;/p&gt;

&lt;p&gt;As we embark on this journey, let's keep in mind that SPOF, in this guide, specifically refers to potential unavailability/ functionality failures within external tools and SaaS solutions. From common tools like CRM software to payment systems and expert automation platforms, we'll unravel not just the challenges but also the key markers that indicate reliability in the world of external tech solutions.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;The Reality of Outside Tools&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;In the fast-paced world of technology, the acceptance of Single Points of Failure (SPOF) isn't a compromise; it's a strategic trade-off for gaining access to the most advanced outsourced technology.  What are the trade-offs? -&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Immediate Time-to-Value:&lt;/strong&gt; Opting for external tools acknowledges the SPOF risk but provides businesses with immediate access to complex functionalities. This trade-off allows companies to jumpstart their operations without investing valuable time in building intricate systems.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Functional Depth and Expertise:&lt;/strong&gt; External tools often come with a level of functional depth that is challenging to replicate in-house. Businesses accept the SPOF risk because the depth and expertise offered by these tools far outweigh the potential risks associated with a Single Point of Failure.‍&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Resource re-allocation:&lt;/strong&gt; By embracing external tools, companies can concentrate on their core competencies. Tools like Stripe and Segment provide such specialized functionality that they become synonymous with their respective categories, allowing businesses to leverage the expertise without having to reinvent the wheel.&lt;/li&gt;
&lt;/ol&gt;

&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%2Foj82vq10m0ixuadj4ddr.png" 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%2Foj82vq10m0ixuadj4ddr.png" alt="how stripe and segment have become synonymous to the category overcoming reliability issues in the longrun" width="800" height="971"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So based on the above examples, this is how we sum it up: In the ever-changing landscape of technology, the decision to accept SPOF as a trade-off for accessing advanced outsourced technology is a rational one. Examples like Stripe and Segment showcase that businesses, more often than not, find the decision matrix tilted in favour of leveraging external tools.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Reality in today’s businesses&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;In corporate discussions, the desire to minimize risks associated with external tools is a common thread woven into various organizational initiatives, audit considerations, disaster recovery plans, and the aspirations of internal teams to be self-sustaining.&lt;/p&gt;

&lt;p&gt;While each of these motivations may seem justifiable independently, the challenge lies in striking a balance between risk mitigation and resource optimization. Let's explore the two predominant approaches businesses can consider when dealing with the Single Point of Failure (SPOF) dilemma.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Pursuit of building internal Back-Up Systems&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The approach of building internal back-up systems is grounded in the idea of self-sufficiency, especially while fearing external tool downtimes or failures. This suggests creating primitive functional systems internally, serving as a safety net for times when external tools experience disruptions.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;The Pitfalls:&lt;/strong&gt;
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Resource Trade-Offs:&lt;/strong&gt; The reality is that building and maintaining internal back-up systems are resource-intensive endeavors. It requires a significant investment of time, talent, and financial resources, diverting focus from core business functions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Primitive Functionality:&lt;/strong&gt; Internal systems built as backups often start with basic functionalities. In the case of working with a complex tool like Stripe, replicating its capabilities internally can be an extensive undertaking.&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;Even as internal development projects hold allure, the reality, as depicted in &lt;a href="https://www.gremlin.com/chaos-engineering#maximizing-resilience"&gt;Gremlin's Chaos Engineering report&lt;/a&gt;, is striking. A significant percentage of outages stem from unforeseen interdependencies and vulnerabilities in internally managed systems. This statistic serves as a compelling reminder of the uphill battle internal teams face in achieving reliability benchmarks.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;When it Makes Sense:&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;This approach might be justifiable for tech giants like Amazon or Facebook, where the potential loss of business due to external tool downtimes is substantial enough to outweigh the costs of internal development and maintenance.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Building and Innovating Best Practices: A Logical Alternative&lt;/strong&gt;
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;The Rational Path&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;A more logical alternative is to innovate on tool evaluation practices. Instead of seeking SPOF-free solutions, the focus shifts to finding tools that are more reliable than anything built internally. This perspective recognizes SPOF as an acceptable risk when measured from a relative standpoint.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;The Logic&lt;/strong&gt;
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Acceptable Risk:&lt;/strong&gt; This approach acknowledges that absolute SPOF elimination is challenging. The goal is to choose tools that, in relative terms, minimize risks and provide a more dependable foundation for operations.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Comparative Evaluation:&lt;/strong&gt; Businesses evaluate external tools not by their ability to eliminate SPOF entirely but by their track record, responsiveness, and commitment to continuous improvement. It's about choosing tools that, in practice, prove to be more reliable than their internal counterparts.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now let's look at the best practices that new age technology leaders use while evaluating external SaaS tools in their tech stack.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;12 Parameters for Evaluating external SaaS for reliability&lt;/strong&gt;
&lt;/h2&gt;

&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%2Fr3nl9lbac8nclx6r07ct.png" 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%2Fr3nl9lbac8nclx6r07ct.png" alt="Single Point of Failure" width="718" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As technology leaders dive into evaluating external tools, it's vital to look beyond the surface. Key parameters act as markers for reliability.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Legacy:&lt;/strong&gt; For How Long This Software Has Been in Use:Longevity often speaks to dependability. Tools that have been around have weathered tech changes, proving their adaptability over time.&lt;br&gt;
&lt;strong&gt;2. Transparency on Uptimes:&lt;/strong&gt; Being open about uptime is a sign of reliability. Tools that share their uptime statistics show a commitment to honesty and accountability.&lt;br&gt;
&lt;strong&gt;3. Historical Uptimes:&lt;/strong&gt; Past performance indicates future behavior. Consistently high uptimes build confidence in a tool's reliability.&lt;br&gt;
&lt;strong&gt;4. Contractual Guarantees on Uptimes:&lt;/strong&gt; A written commitment adds assurance. Tools with contractual guarantees on uptimes show confidence in their abilities.&lt;br&gt;
&lt;strong&gt;5. People Building the Product, Their Expertise, and Background:&lt;/strong&gt; The team behind a tool matters. A diverse, experienced team is better equipped to handle challenges and ensure ongoing improvement.&lt;br&gt;
&lt;strong&gt;6. Other Customers Trusting Their Product:&lt;/strong&gt; Customer trust is a powerful sign. If well-respected organizations rely on a tool, it's likely dependable.&lt;br&gt;
&lt;strong&gt;7. How Robust is Disaster Recovery Setup:&lt;/strong&gt; Being ready for disasters is crucial. Tools with robust recovery setups show a proactive approach to risks.&lt;br&gt;
&lt;strong&gt;8. Compliance with SOC 2, ISO, and Other Audit Certifications:&lt;/strong&gt; Adherence to industry standards shows commitment to security. Tools with certifications exhibit dedication to maintaining a secure environment.&lt;br&gt;
&lt;strong&gt;9. Continuous Improvement Practices:&lt;/strong&gt; Reliable tools evolve. Checking a tool's commitment to continuous improvement, like regular updates and user feedback response, shows adaptability and longevity.&lt;br&gt;
&lt;strong&gt;10. Scalability:&lt;/strong&gt; Scalability is vital for growing businesses. Tools designed to grow with demands provide a reliable foundation for future growth.&lt;br&gt;
&lt;strong&gt;11. Support and Responsiveness:&lt;/strong&gt; In challenges, responsive support is crucial. Evaluating a tool's support system ensures assistance when needed.&lt;br&gt;
&lt;strong&gt;12. Vendor lock-ins:&lt;/strong&gt; Smart companies will lock in critial SaaS vendors with long term contracts to ensure continuity of services.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Conclusion:&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;As technology and product leaders navigate the tech landscape, the quest for a SPOF-free infrastructure becomes a pragmatic pursuit. Third-party tools, by default, introduce SPOF considerations, but it's a reality embraced by smart tech leaders. The evaluation lens shifts from absolute elimination to relative mitigation, trusting data, and considering a spectrum of factors beyond SPOF. In a world where risk management is key, choosing expert tools becomes a strategic imperative for a robust and dependable tech infrastructure.&lt;/p&gt;

&lt;p&gt;‍&lt;/p&gt;

</description>
      <category>singlepointoffailure</category>
      <category>reliability</category>
      <category>devinfra</category>
      <category>saas</category>
    </item>
    <item>
      <title>Elevate your JavaScript game with essential ES6 tricks!</title>
      <dc:creator>Pranav Badami</dc:creator>
      <pubDate>Sun, 19 Nov 2023 17:21:49 +0000</pubDate>
      <link>https://dev.to/fyno/best-javascript-es6-tricks-514h</link>
      <guid>https://dev.to/fyno/best-javascript-es6-tricks-514h</guid>
      <description>&lt;p&gt;Embracing ES6 (ECMAScript 2015) is like unlocking a treasure trove of features that not only elevate your JavaScript game but also transform your coding journey into a more enjoyable and efficient experience. In this blog, we'll dive into some of the best ES6 tricks that will not only enhance the readability of your code but also empower you to write more concise and expressive programs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Arrow functions
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2F1%2A3BK_UMTK8T2GGnrt4nKhxA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2F1%2A3BK_UMTK8T2GGnrt4nKhxA.png" alt="Arrow Function"&gt;&lt;/a&gt;&lt;br&gt;
ES6 introduces arrow functions, providing a more concise syntax for writing anonymous functions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Traditional Function
function add(a, b) {
  return a + b;
}

// Arrow Function
const add = (a, b) =&amp;gt; a + b;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Getting the previous value of the &lt;code&gt;state&lt;/code&gt; in the &lt;code&gt;setState&lt;/code&gt; call using the &lt;code&gt;useState&lt;/code&gt; hook.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// A useState hook initialisation
const [state, setState] = useState(0)

// Updating the state w.r.t to previous value
setState(prev =&amp;gt; prev + 1)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let arr = ['one','two','three']

// Map through the array
arr.map(number =&amp;gt; (
   console.log(number)
)}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Destructuring Literals
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffzle2u1uj0vtn5derqx8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffzle2u1uj0vtn5derqx8.png" alt="Destructuring JS literals"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Destructuring allows you to extract values from &lt;code&gt;arrays&lt;/code&gt; or &lt;code&gt;objects&lt;/code&gt; and assign them to variables in a more intuitive way.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Array Destructuring
const [first, second] = [1, 2];

// Object Destructuring
const { name, age } = { name: 'John', age: 30 };
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Destructuring function parameters and return value, also incase you are using some date being returned &lt;code&gt;asynchronously&lt;/code&gt;/&lt;code&gt;API call&lt;/code&gt; make sure to handle the case when the value you are trying to destructure from is &lt;code&gt;undefined&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const doSomething = ({name, age}) =&amp;gt; {
 return {name , age}
}

const {name, age} = doSomething({name: 'John Doe', age: 24})

// Data returned from an API call
const data = getDate()

//Destructuring
const {name, age} = data || {}

//Directly destructuring 
const {name, age} = getData() || {}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Spread and Rest operator
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1358%2F1%2Ax70lFgXw_qyuVtn1C1nclg.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1358%2F1%2Ax70lFgXw_qyuVtn1C1nclg.jpeg" alt="Spread and Rest"&gt;&lt;/a&gt;&lt;br&gt;
The spread operator &lt;code&gt;(...)&lt;/code&gt; allows you to spread elements of an &lt;code&gt;array&lt;/code&gt; or &lt;code&gt;object&lt;/code&gt;, while the &lt;code&gt;rest&lt;/code&gt; parameter collects remaining arguments into an &lt;code&gt;array&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Spread Operator
const arr = [1, 2, 3];
const newArr = [...arr, 4, 5];

// Rest Parameter
const sum = (...numbers) =&amp;gt; {
  return numbers.reduce((acc, num) =&amp;gt; acc + num, 0);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;⭐️ One of the most useful application of the spread operator is while &lt;code&gt;updating&lt;/code&gt;/&lt;code&gt;altering&lt;/code&gt; one value of an &lt;code&gt;object&lt;/code&gt;, retaining all the other values as it is&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const [obj, setObj] = useState({ name: 'John Doe', location: { city: "Bengaluru", state: "Karnataka" } })

//Update only the city from 'Bengaluru' to 'Mysuru'
setObj(prev =&amp;gt; ({...prev, location: {...prev.location, city: 'Mysuru'}}))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Template Literals
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.dmcindoe.dev%2Fimages%2Fjs-template-literals.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.dmcindoe.dev%2Fimages%2Fjs-template-literals.png" alt="Template Literals"&gt;&lt;/a&gt;&lt;br&gt;
Template literals provide a more flexible and readable way to &lt;code&gt;concatenate&lt;/code&gt; strings, including &lt;code&gt;variables&lt;/code&gt; and &lt;code&gt;expressions&lt;/code&gt;. This can be used to declare a &lt;code&gt;multiline&lt;/code&gt; string.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const name = 'World';
console.log(`Hello, ${name}!`);

const description = `My name is ${name}
I am from Bengaluru
I'm stuck in traffic`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These are a few tricks that can make your code cleaner, maintainable and easier to write overall. I might have missed out on a few of them, but these are the ones that actually make my life easier on an everyday basis. Happy Coding...&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Top 10 react packages for SaaS platforms</title>
      <dc:creator>Pranav Badami</dc:creator>
      <pubDate>Sat, 04 Nov 2023 10:23:48 +0000</pubDate>
      <link>https://dev.to/fyno/top-10-react-packages-for-saas-platforms-48ea</link>
      <guid>https://dev.to/fyno/top-10-react-packages-for-saas-platforms-48ea</guid>
      <description>&lt;h2&gt;
  
  
  Why Use React Libraries?
&lt;/h2&gt;

&lt;p&gt;When it comes to building a product with React, going it alone can be quite a challenge. While it's not impossible, it's certainly a lot easier—and often wiser—to seek assistance from the vast world of open-source packages. React libraries are like your trusty companions in the development journey, simplifying complex tasks, enhancing functionality, and accelerating your project's progress. In this blog post, we'll explore the top 10 React libraries that can be your go-to resources, making your React development experience more efficient and enjoyable. So, without further ado, let's delve into the world of React libraries.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. &lt;a href="https://tanstack.com/query/v3/docs/react/overview" rel="noopener noreferrer"&gt;React-Query&lt;/a&gt; : Your Ultimate Query and Mutation Companion
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdecode.agency%2Fwp-content%2Fuploads%2F2023%2F05%2FReact-Query-logo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdecode.agency%2Fwp-content%2Fuploads%2F2023%2F05%2FReact-Query-logo.png" alt="React-Query"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the ever-evolving world of React development, optimizing queries (GET requests) and mutations (POST, PUT, DELETE) can be quite a task. That's where React-Query comes into play, and it's been a game-changer for us. This library simplifies frontend data management with an intuitive implementation using React hooks, offering a plethora of advantages that make it a must-have in your toolkit:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Easy and simplified query management&lt;/li&gt;
&lt;li&gt;Infinite scroll/Pagination for queries&lt;/li&gt;
&lt;li&gt;Effortless Invalidation and Data Refetching&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/pranav_badami/maintaining-query-cache-with-react-query-m3a"&gt;Cache management&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Robust Error handling&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. Streamline Form Management with &lt;a href="https://react-hook-form.com/get-started" rel="noopener noreferrer"&gt;React-Hook-Form&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1400%2Fformat%3Awebp%2F1%2AFgWMPNlUpjYKhSe7SbOSFQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1400%2Fformat%3Awebp%2F1%2AFgWMPNlUpjYKhSe7SbOSFQ.png" alt="React-Hook0=-Form"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Forms are a cornerstone of web applications, but managing them can often be a daunting task. Dynamic field rendering, state management, and validations can quickly become a maze of complexity. If you've ever found yourself tangled in the web of form-related challenges, React-Hook-Form is here to rescue you. Here is what react-hook-form has to offer:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A simple hook which helps you initialise your form and provides all the methods that can be used in the &lt;/li&gt;
&lt;li&gt;FormProvider wrapper with useFormContext hook which can help you manage states for clean and maintainable code.&lt;/li&gt;
&lt;li&gt;useFieldsArray hook allows you to provide a dynamic fields form which allows users to add or remove fields.&lt;/li&gt;
&lt;li&gt;Easy form validation using &lt;a href="https://www.npmjs.com/package/@hookform/resolvers" rel="noopener noreferrer"&gt;yup-resolver&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. Unleash Creativity with &lt;a href="https://reactflow.dev/learn" rel="noopener noreferrer"&gt;React-Flow&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fworksolutions.ru%2Fuploads%2F99999999999999999_1_2a116db3f4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fworksolutions.ru%2Fuploads%2F99999999999999999_1_2a116db3f4.png" alt="React-Flow"&gt;&lt;/a&gt;&lt;br&gt;
In the world of SaaS (Software as a Service), one tool that's invaluable for many is the flow builder. It's a canvas where you design the logic and the flow of your application. Among the numerous libraries out there, React-Flow stands out as a true gem, and it's undoubtedly one of the most enjoyable and creative libraries we've had the pleasure of using. Lets see how we can have some fun with this library:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Intuitive Flow Building&lt;/li&gt;
&lt;li&gt;Very easy state management for nodes and edges&lt;/li&gt;
&lt;li&gt;Easily create logic to connect nodes and build a drag and drop flow builder&lt;/li&gt;
&lt;li&gt;No limits or hard and fast rule to use this library. Its upto you, to check how crazy you can get with it.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  4. &lt;a href="https://www.npmjs.com/package/plop" rel="noopener noreferrer"&gt;Plop&lt;/a&gt;: The Micro Generator Framework That Transforms Your Workflow
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fplopjs.com%2Fimages%2Fplop-meta-card.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fplopjs.com%2Fimages%2Fplop-meta-card.jpg" alt="Plop"&gt;&lt;/a&gt;&lt;br&gt;
While not exclusively a React package, Plop has been an unsung hero in our development toolkit. This micro generator framework may not be a household name, but it's an absolute game-changer when it comes to saving time and streamlining repetitive tasks, it helps with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Easy and consistent folder structuring in your project.&lt;/li&gt;
&lt;li&gt;Easy files/folder creation with predefined content inside them.&lt;/li&gt;
&lt;li&gt;Simple pattern to make sure uniformity is maintained, especially while working with large teams&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  5. &lt;a href="https://www.npmjs.com/package/flat" rel="noopener noreferrer"&gt;Flat&lt;/a&gt;: Mastering Object Flattening and Unflattening with Precision
&lt;/h3&gt;

&lt;p&gt;In the world of application development, handling complex nested objects is a common challenge. Whether you're working with JSON data, configuration files, or any application state, object flattening and unflattening can be a cumbersome task. That's where "Flat" comes to the rescue, offering a consistent and reliable solution for maintaining the structure of your objects without altering their underlying values.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Provides flatten and unflatten functions which flatten a nested object and unflatten it back to the original form.
for example:
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const nested_object = {
    "name": "Pranav",
    "age": 24,
    "company": "Fyno",
    "address": {
        "city": "Bengaluru",
        "state": "Karnataka",
        "country": "India"
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;On using flatten(nested_object) we get&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    "name": "Pranav",
    "age": 24,
    "company": "Fyno",
    "address.city": "Bengaluru",
    "address.state": "Karnataka",
    "address.country": "India"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And using unflatten(flattened_object) will give back the original object.&lt;/p&gt;

&lt;h3&gt;
  
  
  6. Simplify File Uploads with &lt;a href="https://react-dropzone.js.org/" rel="noopener noreferrer"&gt;React-Dropzone&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Freact-dropzone%2Freact-dropzone%2Fmaster%2Flogo%2Flogo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Freact-dropzone%2Freact-dropzone%2Fmaster%2Flogo%2Flogo.png" alt="React-Dropzone"&gt;&lt;/a&gt;&lt;br&gt;
In the age of modern web applications, file uploads have become a routine part of our online experiences. Whether you're building an image-sharing platform, document management system, or any application that involves handling files, React-Dropzone is your answer to seamless file upload functionality. With its simple drag-and-drop interface, it empowers you to achieve remarkable feats. Lets see what we can achieve with this library:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Simple drag and drop zone/area where any file can be dropped to select/upload.&lt;/li&gt;
&lt;li&gt;useDropzone react hook, to easily manage and use all methods provided by the library.&lt;/li&gt;
&lt;li&gt;Defining file types to accept and number of files to accept.&lt;/li&gt;
&lt;li&gt;Custom validation for files, like showing accepted and rejected files.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  7. &lt;a href="https://react-hot-toast.com/" rel="noopener noreferrer"&gt;React-Hot-Toast&lt;/a&gt;: Elevating User Interaction with Alerts and Notifications
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Frepository-images.githubusercontent.com%2F319456369%2F53412e80-414d-11eb-91d6-b89ae5d419d2" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Frepository-images.githubusercontent.com%2F319456369%2F53412e80-414d-11eb-91d6-b89ae5d419d2" alt="React-hot-toast"&gt;&lt;/a&gt;&lt;br&gt;
In the realm of user-centric applications, timely communication and feedback are essential. React-Hot-Toast has emerged as a personal favourite among developers for delivering real-time alerts, notifications, and in-app reminders, elevating the user experience to new heights. This library offers a powerful yet straightforward way to enhance user engagement through visual communication.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Very simple to use&lt;/li&gt;
&lt;li&gt;Easily customisable, you can add many sorts of customisation like delay, ttl (time to live) and many more things.&lt;/li&gt;
&lt;li&gt;Designs for these toasts are very flexible and easy to customise according to product design requirements.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  8. &lt;a href="https://www.npmjs.com/package/luxon" rel="noopener noreferrer"&gt;Luxon&lt;/a&gt;: Mastering Time and Timezones for Precision Data Handling
&lt;/h3&gt;

&lt;p&gt;In the world of application development, mastering time and timezone management is a fundamental requirement. Many platforms, whether they deal with analytics, activity logs, or any aspect of data that's time-sensitive, need a robust solution for handling time in different formats and working with timezone offsets. Luxon is that solution, offering a powerful toolkit to manage time with precision and confidence. Any sort of data management which is time sensitive would benefit from:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Comprehensive date and time manipulation&lt;/li&gt;
&lt;li&gt;Timezone support&lt;/li&gt;
&lt;li&gt;Variety of formatting with date and time, as suitable for different use cases&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  9. Empower Non-Technical Users with &lt;a href="https://react-querybuilder.js.org/docs/intro" rel="noopener noreferrer"&gt;React-Query-Builder&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Freact-querybuilder.js.org%2Fimg%2Freact-querybuilder.svg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Freact-querybuilder.js.org%2Fimg%2Freact-querybuilder.svg" alt="React-Query-Builder"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the world of application development, database queries are often a complex and intimidating aspect, particularly for those outside the technical domain. This challenge becomes even more significant in a no-code environment where users are looking for simplicity and empowerment. React-Query-Builder is the answer, simplifying the process of building queries through a user-friendly UI and providing the ability to export in various formats, including JSON, SQL, MongoDB, CEL, and SpEL.&lt;/p&gt;

&lt;h3&gt;
  
  
  10. Elevate User Experience with &lt;a href="https://www.npmjs.com/package/use-query-params" rel="noopener noreferrer"&gt;Use-Query-Params&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;In the realm of web applications, a seamless user experience often hinges on the ability to maintain and share URLs with filters, search parameters, and other states. Use-Query-Params steps in as an indispensable tool, simplifying the process of encoding and decoding data as query parameters. With the useQueryParam hook, it's easy to achieve the fine balance between URL sharing and an enhanced user experience.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Easily maintainable states with URL&lt;/li&gt;
&lt;li&gt;Any data type can be encoded to the query params&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In our journey at &lt;a href="https://www.fyno.io" rel="noopener noreferrer"&gt;Fyno&lt;/a&gt;, these top 10 React libraries have been invaluable allies, simplifying our development process and addressing the diverse requirements that surface in the world of SaaS platforms. If you haven't already explored the potential of these packages, we encourage you to give them a try. They have the power to streamline your development workflow, enhance user experiences, and make life simpler for you too. So, dive in, experiment, and discover how these libraries can elevate your React projects to new heights. Your next big breakthrough might just be a package away.&lt;/p&gt;

</description>
      <category>react</category>
      <category>nextjs</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>React Query - Maintaining Query cache</title>
      <dc:creator>Pranav Badami</dc:creator>
      <pubDate>Fri, 13 Oct 2023 18:16:01 +0000</pubDate>
      <link>https://dev.to/fyno/maintaining-query-cache-with-react-query-m3a</link>
      <guid>https://dev.to/fyno/maintaining-query-cache-with-react-query-m3a</guid>
      <description>&lt;p&gt;React Query has greatly simplified frontend API query handling with improved error management and efficient data caching. However, managing query keys can be challenging, as we discovered at Fyno when dealing with duplicated key names, leading to frustrating hours of debugging. This situation highlights the significance of effective key management. Duplicated keys can lead to data mix-ups and unexpected results. Lets delve into best practices for managing query keys, allowing you to harness React Query's full potential without the hassle of duplicated keys.&lt;/p&gt;

&lt;h2&gt;
  
  
  Old Approach
&lt;/h2&gt;

&lt;p&gt;We create a react query hook for each API call and define the query key cache in the react query hook and if we want to invalidate some query then we had to go find the query key and use the same one. Which is a lot of manual work and when you are trying to be as productive as possible, this can cause issues which will be time consuming to debug.&lt;/p&gt;

&lt;p&gt;Some examples of the old approach:&lt;/p&gt;

&lt;p&gt;1 . Simple Query Key&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { useQuery } from 'react-query'

const getTemplates = () =&amp;gt; {
 // make your API call here
 return response
}

export const useGetTemplates = () =&amp;gt; {
  return useQuery(['templatesList'],() =&amp;gt; getTemplates())
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { useQuery } from 'react-query'

const getEvents = () =&amp;gt; {
 // make your API call here
 return response
}

export const useGetEvents = () =&amp;gt; {
  return useQuery(['eventsList'],() =&amp;gt; getEvents())
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2 . Dynamic Query Key&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { useQuery } from 'react-query'

const getTemplateDetails = () =&amp;gt; {
 // make your API call here
 return response
}

export const useGetTemplateDetails = (name, version) =&amp;gt; {
  return useQuery(['templateDetails', name, version],() =&amp;gt; getTemplateDetails())
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { useQuery } from 'react-query'

const getEventDetails = () =&amp;gt; {
 // make your API call here
 return response
}

export const useGetEventDetails = (name, version) =&amp;gt; {
  return useQuery(['eventDetails', name, version],() =&amp;gt; getEventDetails())
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Let's deep dive into the problem
&lt;/h2&gt;

&lt;p&gt;Following the best practices, we've been using separate React Query hooks for each API call to the backend. However, each query call requires a unique query key to store the API response data, and as our project has grown with new features, we've encountered some challenges:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Query Key Conundrum:&lt;/strong&gt; One of the dilemmas we faced is deciding what query key to assign to the cache for the response data from an API call. It may seem straightforward at first, but as your project evolves, making this decision can become quite a puzzle.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Invalidation and Refetching:&lt;/strong&gt; Figuring out the right query key to invalidate or trigger a refetch based on another API call or a specific action can be like solving a complex puzzle. It's critical to ensure that your data remains up-to-date and accurate.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;The Duplicity Dilemma:&lt;/strong&gt; As we expanded our codebase, we encountered the issue of creating duplicate query keys. This happened when data from various API calls with different responses started to overlap, leading to confusion and unexpected results.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These challenges are not unique, and they can affect the efficiency and maintainability of your project. Lets explore strategies and techniques to tackle these issues head-on, ensuring a smoother development process and a more predictable and reliable application.&lt;/p&gt;




&lt;h2&gt;
  
  
  New Approach
&lt;/h2&gt;

&lt;p&gt;To address these challenges, we took a strategic approach. Firstly, we centralized the creation of all query cache keys for easy accessibility and maintenance. Our goal was to make this process dynamic, allowing customization with specific values while maintaining a standardized approach. &lt;/p&gt;

&lt;h2&gt;
  
  
  Query Keys Factory
&lt;/h2&gt;

&lt;p&gt;Our solution? We call it the "Query Keys Factory." Now, you might wonder why we went with such a name - well, sometimes, cool just sounds cool. It's a nifty little React hook, and its job is simple but incredibly valuable. This hook holds the keys to all the query keys, organized neatly according to the features within our product.&lt;/p&gt;

&lt;p&gt;Create a simple global react hook, you can call it Query Keys Factory to be cool like us.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export const useQueryKeysFactory = () =&amp;gt; {

  //--------Templates-----------&amp;gt; /templates
  const templateKeys = {
    list: ['templatesList'],
    details: (name, version) =&amp;gt; ['templateDetails', name, version]
  }

//--------Events-----------&amp;gt; /events
  const templateKeys = {
    list: ['eventsList'],
    details: (name, version) =&amp;gt; ['eventDetails', name, version]
  }

  return { templateKeys, eventKeys }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the code snippet above, we've showcased a straightforward example of a query cache for two API calls of two features, which in this case, are "Templates" and "Events". These API calls include a listing API, providing a list of all the templates/events, and a details API for retrieving information about a single template/event. What makes this approach especially powerful is the encapsulation of these keys within the templateKeys/eventKeys section. These keys serve as the foundation for all query keys related to the /templates and /events endpoint respectively.&lt;/p&gt;

&lt;p&gt;By centralizing these keys in one place, you gain remarkable accessibility and maintainability. You can easily access them from anywhere in your application, making the management of query keys a breeze. To illustrate how it works in practice, let's consider the implementation of a React Query hook for retrieving the list of templates and events. This way, you can see how this approach seamlessly integrates into your development process, offering a cleaner, more organized way to handle query keys throughout your project.&lt;/p&gt;

&lt;p&gt;1 . Simple Query Key&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { useQuery } from 'react-query'

const getTemplates = () =&amp;gt; {
 // make your API call here
 return response
}

export const useGetTemplates = () =&amp;gt; {
  const { templateKeys } = useQueryKeysFactory()

  return useQuery(templateKeys['list'],() =&amp;gt; getTemplates())
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { useQuery } from 'react-query'

const getEvents = () =&amp;gt; {
 // make your API call here
 return response
}

export const useGetEvents = () =&amp;gt; {
  const { eventKeys } = useQueryKeysFactory()

  return useQuery(eventKeys['list'],() =&amp;gt; getEvents())
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2 . Dynamic Query Key&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { useQuery } from 'react-query'

const getTemplateDetails = () =&amp;gt; {
 // make your API call here
 return response
}

export const useGetTemplateDetails = (name, version) =&amp;gt; {
  const { templateKeys } = useQueryKeysFactory()

  return useQuery(templateKeys['details'](name, version),() =&amp;gt; getTemplateDetails())
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { useQuery } from 'react-query'

const getEventDetails = () =&amp;gt; {
 // make your API call here
 return response
}

export const useGetEventDetails = (name, version) =&amp;gt; {
  const { eventKeys } = useQueryKeysFactory()

  return useQuery(eventKeys['details'](name, version),() =&amp;gt; getEventDetails())
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, let's dive into a straightforward yet powerful scenario: invalidating cache based on another API call. We'll walk you through creating a React Query hook for making a delete template/event request. If this deletion operation succeeds, we'll perform an act of cache magic – invalidating the listing API call's cached data. This little trick ensures that our application always fetches the freshest, most up-to-date data from the backend.&lt;/p&gt;

&lt;p&gt;Here's a sneak peek at how it's done:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { useMutation, useQueryClient } from 'react-query'

const deleteTemplate = template_name =&amp;gt; {
  // Add your API call for deleting the template with name template_name
}

export const useDeleteTemplate = () =&amp;gt; {
  const queryClient = useQueryClient()
  const { templateKeys } = useQueryKeysFactory()

  return useMutation(template_name =&amp;gt; deleteTemplate(template_name), {
    onSuccess: () =&amp;gt; {
       queryClient.invalidateQueries(templateKeys['list'])
       }
   })
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { useMutation, useQueryClient } from 'react-query'

const deleteEvent = event_name =&amp;gt; {
  // Add your API call for deleting the template with name event_name
}

export const useDeleteEvent = () =&amp;gt; {
  const queryClient = useQueryClient()
  const { eventKeys } = useQueryKeysFactory()

  return useMutation(event_name =&amp;gt; deleteTemplate(event_name), {
    onSuccess: () =&amp;gt; {
       queryClient.invalidateQueries(eventKeys['list'])
       }
   })
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There you go – query invalidation made simple. No more hunting for query keys, just trust the Query Keys Factory to handle it for you. It's all about efficiency and letting the tools do the work.&lt;/p&gt;

&lt;p&gt;In conclusion, our exploration of managing query keys with React Query has provided valuable insights. We've introduced the Query Keys Factory as a solution to simplify key management, streamline development, and minimize errors. With this approach, you can confidently handle query keys and optimize your development workflow. Mastering React Query's query keys can significantly improve your experience, making your projects more efficient and reliable. Happy coding!&lt;/p&gt;

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