<?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: Rahul Chaurasia</title>
    <description>The latest articles on DEV Community by Rahul Chaurasia (@therahulchaurasia).</description>
    <link>https://dev.to/therahulchaurasia</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%2F1362939%2Fef41f05d-ab07-4294-9d2a-abde041f066d.png</url>
      <title>DEV Community: Rahul Chaurasia</title>
      <link>https://dev.to/therahulchaurasia</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/therahulchaurasia"/>
    <language>en</language>
    <item>
      <title>Avoid This Sneaky State Bug in Dynamic Routes (React + Next.js)</title>
      <dc:creator>Rahul Chaurasia</dc:creator>
      <pubDate>Sat, 24 May 2025 14:30:00 +0000</pubDate>
      <link>https://dev.to/therahulchaurasia/avoid-this-sneaky-state-bug-in-dynamic-routes-react-nextjs-1755</link>
      <guid>https://dev.to/therahulchaurasia/avoid-this-sneaky-state-bug-in-dynamic-routes-react-nextjs-1755</guid>
      <description>&lt;p&gt;I faced an unexpected issue while working with static pages in a Next.js project. It was a simple carousel component that received images via props and managed its internal state.&lt;/p&gt;

&lt;p&gt;But after navigating to another page, the carousel began to act strangely. The wrong image was selected. Sometimes, it broke entirely. At first glance, nothing had changed — yet clearly, something had.&lt;/p&gt;

&lt;p&gt;This happens because frameworks hide a lot of the complex stuff behind the scenes. It’s not a bug — just one of those things that can trip you up if you don’t understand what’s happening.&lt;/p&gt;

&lt;h2&gt;
  
  
  Going down the rabbit hole.
&lt;/h2&gt;

&lt;p&gt;When we switch to another dynamic page, the route stays the same, so Next.js doesn't remount the main component. Instead, it just changes the props.&lt;br&gt;
Due to this, all the child components in the tree are preserved along with their states.&lt;/p&gt;

&lt;h2&gt;
  
  
  React tree on first load
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;App&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="err"&gt;└──&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;slug&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;tsx &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;slug&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;product-a&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="err"&gt;└──&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Gallery&lt;/span&gt; &lt;span class="nx"&gt;images&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;a1.jpg&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;a2.jpg&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]}&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The gallery is rendered with images for "product-a". The &lt;code&gt;selectedImageIndex&lt;/code&gt; is initialized to 0.&lt;/p&gt;

&lt;h2&gt;
  
  
  User makes a route change
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;App&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="err"&gt;└──&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;slug&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;tsx &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;slug&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;product-b&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="err"&gt;└──&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Gallery&lt;/span&gt; &lt;span class="nx"&gt;images&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;b1.jpg&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;b2.jpg&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]}&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Gallery component was &lt;strong&gt;not unmounted&lt;/strong&gt; during navigation. If the user had previously selected image index 1 on &lt;code&gt;product-a&lt;/code&gt;, that same index remains selected after navigating to &lt;code&gt;product-b&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;And the functionality breaks if &lt;code&gt;product-b&lt;/code&gt; doesn't have any image to serve on index 1.&lt;/p&gt;

&lt;p&gt;This behavior is influenced by both &lt;strong&gt;React&lt;/strong&gt; and &lt;strong&gt;Next.js&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Solution
&lt;/h2&gt;

&lt;p&gt;Instead of Googling, I went straight to ChatGPT like most people do nowadays. There were a couple of straightforward ways to fix it. I implemented one and noted the other as a solid alternative.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Include a unique &lt;strong&gt;key&lt;/strong&gt; whenever calling the gallery component instance.&lt;/li&gt;
&lt;li&gt;Add a useEffect that resets the internal state whenever the props, specifically the images, change.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I haven't tried the second option, but I believe it would provide the necessary granular control for some components.&lt;/p&gt;

&lt;h2&gt;
  
  
  Provinding the key
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;App&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="err"&gt;└──&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;slug&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;tsx &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;slug&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;product-b&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="err"&gt;└──&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Gallery&lt;/span&gt; &lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;product-b&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;images&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;b1.jpg&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;b2.jpg&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]}&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The key would change with the product, causing the component to unmount and remount. Upon successful operation, all the states would be set to default.&lt;/p&gt;

&lt;p&gt;This approach was able to solve my issue effectively.&lt;/p&gt;

&lt;h2&gt;
  
  
  To wrap things up
&lt;/h2&gt;

&lt;p&gt;The issue reminds us that modern frameworks do a lot of heavy lifting behind the scenes, which is fantastic! However, it also highlights the importance for developers to understand what's happening under the hood.&lt;/p&gt;

&lt;p&gt;By knowing how React and Next.js handle component lifecycles and state, we can avoid these pitfalls and write more predictable, robust applications. &lt;br&gt;
If you’ve encountered similar challenges or have tips to share, I’d love to hear about them&lt;/p&gt;

</description>
      <category>react</category>
      <category>webdev</category>
      <category>nextjs</category>
      <category>programming</category>
    </item>
    <item>
      <title>How to learn something new while solving errors</title>
      <dc:creator>Rahul Chaurasia</dc:creator>
      <pubDate>Wed, 19 Feb 2025 08:14:42 +0000</pubDate>
      <link>https://dev.to/therahulchaurasia/how-to-learn-something-new-while-solving-errors-1744</link>
      <guid>https://dev.to/therahulchaurasia/how-to-learn-something-new-while-solving-errors-1744</guid>
      <description>&lt;p&gt;Hey, fellow techies,&lt;/p&gt;

&lt;p&gt;I have been having the itch to write about something on the internet. But I did not know what to write about. &lt;/p&gt;

&lt;p&gt;Only recently, I had some enlightenment. What if I wrote about a topic that I was learning? I could share my learning experience with others, the "barriers," the "Aha" moments, the "Why does this code work?" and much more.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Cut to the chase&lt;/em&gt;, I decided to learn unit testing in React applications. &lt;/p&gt;

&lt;p&gt;And the journey begins...&lt;/p&gt;

&lt;p&gt;At first, I did not know where to begin. So, I started wandering the internet and found some shiny terms such as End to End testing (E2E),  Test Driven Development (TDD), Code Driven Development (CDD), etc. But most of them did not make much sense to me.&lt;/p&gt;

&lt;p&gt;Still, it was a good place to get my toes wet. I found a few videos on YouTube explaining the shiny terms and their use cases. Through YouTube, I was able to learn how to set up test cases.&lt;/p&gt;

&lt;p&gt;These two videos, by programming with mosh, helped me understand most of the stuff:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=zuKbR4Q428o&amp;amp;t=2110s" rel="noopener noreferrer"&gt;JavaScript Unit Testing Tutorial for Beginners&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=8Xwq35cPwYg" rel="noopener noreferrer"&gt;React Testing for Beginners&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But, the million dollar question was, where do I use this? Well, we haven't tried this way of testing the applications at my place of work. So, I took the plunge.&lt;/p&gt;

&lt;p&gt;The website is built using Next JS with pages router, Chakra UI, and React query. So, I set everything up like in the tutorials and wrote my first test case.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;BAM!!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Errors start popping up one by one. I get a total of 4 different types of errors.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Error with absolute imports&lt;/strong&gt;&lt;br&gt;
Our project uses absolute imports, i.e., &lt;code&gt;@/components/ui/button&lt;/code&gt; like other Next JS projects. It has been the standard approach with Next JS for a while now. The &lt;code&gt;tsconfig.json&lt;/code&gt; file contains the "baseUrl" option that is set as the root directory of the project.&lt;/p&gt;

&lt;p&gt;However, the testing library only uses its config file. So, it was going nuts within the first line of code. I started googling for solutions and found a few that did not work for me. But all is not lost, and a solution appears. You would need to install the "path" package from the NPM registry and use its resolve method in your config.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;p.s. I have attached the code snippet below this error because you can solve both of them by updating the config file&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. React is not defined&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When I try to render one of the components, there is a big error: React is not defined (It's funny because this is a React project). We were using a higher version of react &amp;gt;= 17. So there's no compulsion to import react.&lt;/p&gt;

&lt;p&gt;But the testing library thinks this is unacceptable. So, I tried to find a solution to this. And it involves installing a plugin and updating the vitest config file.&lt;br&gt;
&lt;/p&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="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;resolve&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;path&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;defineConfig&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;vitest/config&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;react&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@vitejs/plugin-react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nf"&gt;defineConfig&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;plugins&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nf"&gt;react&lt;/span&gt;&lt;span class="p"&gt;()],&lt;/span&gt;
  &lt;span class="na"&gt;test&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;environment&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;jsdom&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;alias&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt; &lt;span class="na"&gt;find&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;replacement&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;__dirname&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./src&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&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;&lt;strong&gt;3. Next Router is not mounted&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Another error that I encountered on the way was related to the next router not being mounted. Some quick research showed me that the next router cannot be used outside a Next JS application. The next documentation asked me to mock the router, and I thought it was funny.&lt;/p&gt;

&lt;p&gt;This is the only solution I was able to find through chatGPT for the above error.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;vi&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;mock&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;next/router&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;useRouter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;push&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;vi&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fn&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
    &lt;span class="na"&gt;query&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{},&lt;/span&gt;
    &lt;span class="na"&gt;pathname&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;asPath&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;vi&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fn&lt;/span&gt;&lt;span class="p"&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;&lt;strong&gt;4. No QueryClient set, use QueryClientProvider to set one&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This was one of the straightforward ones. To use react query, the entire code needs to be wrapped inside the queryClientProvider by react query. The component, when working as a system, is wrapped correctly and works fine. &lt;/p&gt;

&lt;p&gt;But, as I said, the testing library renders a specific component, leading to the error. This error is somewhat similar to the error mentioned above. We tried using something out of context and, as a result, got an error.&lt;br&gt;
&lt;/p&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;queryClient&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;QueryClient&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="c1"&gt;// Wrap the component in QueryClientProvider&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;container&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;render&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;QueryClientProvider&lt;/span&gt; &lt;span class="nx"&gt;client&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;queryClient&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;SignUpForm&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;/QueryClientProvider&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I haven't had much luck with testing our application. Yet, I still wanted to share what I have learned so far about testing and solving errors while setting up test cases.&lt;/p&gt;

&lt;p&gt;I hope this article is of some help to you.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>testing</category>
      <category>frontend</category>
    </item>
  </channel>
</rss>
