<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Dhokia Rinidh</title>
    <description>The latest articles on Forem by Dhokia Rinidh (@rinidh).</description>
    <link>https://forem.com/rinidh</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%2F2497632%2F036c256f-05d6-4c52-972e-0f0c3ce185ba.jpg</url>
      <title>Forem: Dhokia Rinidh</title>
      <link>https://forem.com/rinidh</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/rinidh"/>
    <language>en</language>
    <item>
      <title>Summary of insights into traditional CSS Grid &amp; Flexbox</title>
      <dc:creator>Dhokia Rinidh</dc:creator>
      <pubDate>Sun, 08 Mar 2026 18:14:15 +0000</pubDate>
      <link>https://forem.com/rinidh/summary-of-insights-into-traditional-css-grid-flexbox-1bc8</link>
      <guid>https://forem.com/rinidh/summary-of-insights-into-traditional-css-grid-flexbox-1bc8</guid>
      <description>&lt;p&gt;Hello folks. Many CSS layout properties are interdependent and behave differently depending on how they are combined. A practical way to remember them is to mentally group properties based on &lt;strong&gt;the direction they control&lt;/strong&gt; and &lt;strong&gt;whether they apply to the container or the items&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Inline Direction (left → right in most writing modes)&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Properties beginning with &lt;code&gt;justify-&lt;/code&gt; generally control alignment along the &lt;strong&gt;inline axis&lt;/strong&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;justify-content&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Used on the &lt;strong&gt;container&lt;/strong&gt; to align &lt;strong&gt;tracks (in grid)&lt;/strong&gt; or &lt;strong&gt;flex items (in flexbox)&lt;/strong&gt; along the inline axis when extra space is available.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;justify-items&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Used on the &lt;strong&gt;grid container&lt;/strong&gt; to define the default alignment of &lt;strong&gt;grid items inside their grid cells&lt;/strong&gt; along the inline axis.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;justify-self&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Used on a &lt;strong&gt;grid item&lt;/strong&gt; to override &lt;code&gt;justify-items&lt;/code&gt; for that specific item.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Block Direction (top → bottom in most writing modes)&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Properties beginning with &lt;code&gt;align-&lt;/code&gt; generally control alignment along the &lt;strong&gt;block axis&lt;/strong&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;align-content&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Used on the &lt;strong&gt;container&lt;/strong&gt; to align &lt;strong&gt;grid tracks or flex lines&lt;/strong&gt; along the block axis when there is extra space.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;align-items&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Used on the &lt;strong&gt;container&lt;/strong&gt; to set the default alignment of items along the &lt;strong&gt;cross axis&lt;/strong&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In &lt;strong&gt;grid&lt;/strong&gt;, the cross axis equals the &lt;strong&gt;block axis&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;In &lt;strong&gt;flexbox&lt;/strong&gt;, the cross axis depends on &lt;code&gt;flex-direction&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;code&gt;align-self&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Used on an &lt;strong&gt;individual item&lt;/strong&gt; to override the &lt;code&gt;align-items&lt;/code&gt; value for that item.&lt;/p&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  Restrictions / Differences
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;justify-items&lt;/code&gt; &lt;strong&gt;does not work in flexbox&lt;/strong&gt;. It only applies to &lt;strong&gt;grid containers&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;align-content&lt;/code&gt; works in &lt;strong&gt;both grid and flexbox&lt;/strong&gt;, but in flexbox it only has an effect when there are &lt;strong&gt;multiple flex lines&lt;/strong&gt; (e.g., when &lt;code&gt;flex-wrap: wrap&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;With &lt;code&gt;grid-auto-flow: row&lt;/code&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Columns&lt;/strong&gt; are determined by &lt;code&gt;grid-template-columns&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;If there are more items than available cells, &lt;strong&gt;new rows are automatically created&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;With &lt;code&gt;grid-auto-flow: column&lt;/code&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Rows&lt;/strong&gt; are determined by &lt;code&gt;grid-template-rows&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Extra items create &lt;strong&gt;new columns&lt;/strong&gt; instead.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;code&gt;grid-template-columns&lt;/code&gt; / &lt;code&gt;grid-template-rows&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Define the &lt;strong&gt;explicit grid&lt;/strong&gt; (the tracks you explicitly declare).&lt;/p&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;code&gt;grid-auto-columns&lt;/code&gt; / &lt;code&gt;grid-auto-rows&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Define the size of &lt;strong&gt;implicitly created tracks&lt;/strong&gt; when extra items require new rows or columns.&lt;/p&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  Dynamic Layout Patterns
&lt;/h3&gt;

&lt;p&gt;These are common responsive grid patterns.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;grid-template-columns: repeat(auto-fill, 200px)&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Creates columns of &lt;strong&gt;fixed width (200px)&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;The browser fits &lt;strong&gt;as many columns as possible&lt;/strong&gt; in the container.&lt;/li&gt;
&lt;li&gt;Extra space may remain at the end of the row.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;grid-template-columns: repeat(auto-fill, minmax(200px, 1fr))&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Each column is &lt;strong&gt;at least 200px&lt;/strong&gt; but can grow.&lt;/li&gt;
&lt;li&gt;Remaining space is distributed using &lt;code&gt;1fr&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;When there is enough space for another 200px column, the browser &lt;strong&gt;adds a new column automatically&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Other Useful Notes
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;grid-template-areas: '. . .' '. . .'&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Each string represents a &lt;strong&gt;row&lt;/strong&gt;, and each value represents a &lt;strong&gt;column cell&lt;/strong&gt;.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;grid-template-areas:
'. . .'
'. . .';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This creates a &lt;strong&gt;3-column × 2-row grid&lt;/strong&gt;, but unlike &lt;code&gt;grid-template-columns&lt;/code&gt; / &lt;code&gt;grid-template-rows&lt;/code&gt;, it is mainly used to &lt;strong&gt;name layout areas&lt;/strong&gt;, not just define track counts.&lt;/p&gt;

&lt;h3&gt;
  
  
  Track Sizing Keywords
&lt;/h3&gt;

&lt;p&gt;When defining columns or rows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;min-content&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Shrinks the track to the &lt;strong&gt;smallest size possible without overflowing&lt;/strong&gt;. Text wraps as needed, typically down to the &lt;strong&gt;longest unbreakable word&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;max-content&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Expands the track so &lt;strong&gt;all content fits on one line&lt;/strong&gt; (no wrapping). It does not grow further even if the container expands.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;fit-content(200px)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Allows the track to grow to fit its content but &lt;strong&gt;never exceed 200px&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;auto&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Sizes the track based on content and available space. It behaves somewhat like &lt;code&gt;minmax(min-content, max-content)&lt;/code&gt; but can also stretch when free space exists.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;These random cheat-sheet style bullets can be handy for &lt;strong&gt;quick recall while coding&lt;/strong&gt;, instead of revisiting a long article and forcing your brain through lots of context switching.&lt;/p&gt;

&lt;p&gt;As usual, feel free to add more insights, point out mistakes, or share your own mental models for remembering CSS layout rules.&lt;/p&gt;

</description>
      <category>css</category>
      <category>beginners</category>
      <category>cheatsheet</category>
    </item>
    <item>
      <title>Test Isolation vs. Mocking Mechanics in Express</title>
      <dc:creator>Dhokia Rinidh</dc:creator>
      <pubDate>Fri, 30 Jan 2026 18:25:01 +0000</pubDate>
      <link>https://forem.com/rinidh/test-isolation-vs-mocking-mechanics-in-express-1kg0</link>
      <guid>https://forem.com/rinidh/test-isolation-vs-mocking-mechanics-in-express-1kg0</guid>
      <description>&lt;p&gt;Hello everyone,&lt;/p&gt;

&lt;p&gt;It’s been a while since I last shared something—back when I was deep into &lt;a href="https://dev.to/rinidh/building-forms-with-react-hook-form-part-2-3005"&gt;React Hook Form&lt;/a&gt;. After wrapping up my frontend, I shifted focus to gluing all pieces together and building full &lt;a href="https://www.mongodb.com/resources/languages/mern-stack#:~:text=MERN%20is%20a%20pre%2Dbuilt,a%20client%2Dside%20JavaScript%20framework" rel="noopener noreferrer"&gt;MERN stack&lt;/a&gt; applications (more on that another time...).&lt;/p&gt;

&lt;p&gt;While writing unit tests for the backend of one of these apps, I ran into a subtle but important realization: mocking dependencies and clearing mock state alone is not always enough to guarantee proper test isolation—especially when testing Express routing logic.&lt;/p&gt;

&lt;h3&gt;
  
  
  The scenario
&lt;/h3&gt;

&lt;p&gt;Consider the following Express router:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// product.route.ts&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;express&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;express&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&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;createProduct&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;deleteProduct&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;getAllProducts&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;updateProduct&lt;/span&gt;&lt;span class="p"&gt;,&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="s2"&gt;../controllers/product.controller.js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;router&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;express&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Router&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="cm"&gt;/**
 * Endpoint: /api/products
 */&lt;/span&gt;
&lt;span class="nx"&gt;router&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;getAllProducts&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;router&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;createProduct&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;router&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;put&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/:id&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;updateProduct&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;router&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;delete&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/:id&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;deleteProduct&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="nx"&gt;router&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Suppose our goal is simple: verify that each HTTP method is correctly wired to its corresponding controller. We are not interested in the controller logic itself, so mocking the controllers is a perfectly reasonable approach.&lt;/p&gt;

&lt;p&gt;Since my project used Typescript and ESM, I preferred Vitest for testing. We can mock the controllers like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&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="s2"&gt;../controllers/product.controller.js&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;getAllProducts&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="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
    &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;getAllProducts called&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;createProduct&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="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
    &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;201&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;createProduct called&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;updateProduct&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="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
    &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;updateProduct called&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;deleteProduct&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="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
    &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;deleteProduct called&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And before each test, we typically clear mocks:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&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;clearAllMocks&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This does reset:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;call counts (.mock.calls)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;recorded arguments&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;mock results (.mock.results)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;However, this is where a common misconception appears.&lt;/p&gt;

&lt;h3&gt;
  
  
  What clearing mocks does not reset
&lt;/h3&gt;

&lt;p&gt;Clearing mocks does not reset the &lt;strong&gt;runtime state&lt;/strong&gt; of your application. Particularly, it doesn't:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Recreate the Express app or router instance&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Reset Express’ internal routing stack&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Undo mutations to req, res, or app objects made by previous tests&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Reset middleware side effects&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Reload cached modules from Node’s module system&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Note that Express routers are &lt;a href="https://dev.to/imsushant12/securing-web-applications-stateful-vs-stateless-systems-authentication-and-authorization-in-nodejs-b1m"&gt;stateful objects&lt;/a&gt;. Once a router is created and attached to an app, its middleware stack and handlers persist for the lifetime of that app instance.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why this matters in tests
&lt;/h3&gt;

&lt;p&gt;If you reuse the same Express app across tests, subtle state can leak:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;A previous test may mutate &lt;code&gt;req.headers&lt;/code&gt;, &lt;code&gt;req.body&lt;/code&gt;, or &lt;code&gt;res.locals&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Middleware may attach data to &lt;code&gt;req&lt;/code&gt; that subsequent tests unexpectedly inherit and misuse&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Order-dependent behavior can emerge when tests rely on shared app state&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This can lead to tests that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Pass or fail depending on execution order&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Fail intermittently&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Give false confidence about route behavior&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Mock isolation alone cannot protect you from this class of problems.&lt;/p&gt;

&lt;h3&gt;
  
  
  The correct approach: reset runtime state
&lt;/h3&gt;

&lt;p&gt;For modules with stateful dependencies (such as Express apps) the solution is twofold:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Reset mock state (call counts, return values, spies)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Recreate the runtime environment (new app instance per test)&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;express&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;Express&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="s2"&gt;express&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;router&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;./routes&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nf"&gt;describe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Product routes&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="kd"&gt;let&lt;/span&gt; &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Express&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;createTestApp&lt;/span&gt; &lt;span class="o"&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;express&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;express&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
    &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/api&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;router&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;

  &lt;span class="nf"&gt;beforeEach&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="nx"&gt;vi&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;clearAllMocks&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;restoreAllMocks&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="nx"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;createTestApp&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;

  &lt;span class="c1"&gt;// tests go here&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By constructing a fresh Express app for each test, you guarantee:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;No shared routing or middleware state&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Predictable request/response objects&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;True&lt;/em&gt; test isolation&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Takeaway
&lt;/h3&gt;

&lt;p&gt;Mocking is about behavior substitution. Test isolation is about state control.&lt;/p&gt;

&lt;p&gt;When testing Express routes, clearing mocks addresses only half the problem. To achieve reliable and deterministic tests, you must also reset—or recreate—the application runtime itself.&lt;/p&gt;

&lt;p&gt;Feel free to drop your own experiences and lessons below.&lt;/p&gt;

&lt;p&gt;Happy testing guys👋&lt;/p&gt;

</description>
      <category>testing</category>
      <category>beginners</category>
      <category>express</category>
    </item>
    <item>
      <title>Building Forms with React Hook Form (Part 2)</title>
      <dc:creator>Dhokia Rinidh</dc:creator>
      <pubDate>Sat, 29 Nov 2025 19:03:15 +0000</pubDate>
      <link>https://forem.com/rinidh/building-forms-with-react-hook-form-part-2-3005</link>
      <guid>https://forem.com/rinidh/building-forms-with-react-hook-form-part-2-3005</guid>
      <description>&lt;p&gt;Hey guys!&lt;/p&gt;

&lt;p&gt;I kept exploring React Hook Form (RHF) over the past week, and something became very clear: it’s one of the &lt;strong&gt;most performant and thoughtful form libraries in the React ecosystem&lt;/strong&gt;. After sharing a set of beginner-friendly lessons in my previous post, I’m back with more discoveries that will hopefully save you from some debugging headaches.&lt;/p&gt;

&lt;p&gt;If you haven’t read the first article, you can find it here:&lt;/p&gt;

&lt;p&gt;➡️ &lt;a href="https://dev.to/rinidh/building-forms-using-react-hook-form-d48"&gt;Building Forms Using React Hook Form #1&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now—on to the juicy bits.&lt;/p&gt;




&lt;h2&gt;
  
  
  More Lessons &amp;amp; Tips
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. &lt;code&gt;useWatch()&lt;/code&gt; and re-renders
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;useWatch()&lt;/code&gt; lets you track field values &lt;em&gt;without re-rendering the entire form&lt;/em&gt;, but only if you watch fields &lt;strong&gt;narrowly and intentionally&lt;/strong&gt;. Watching a large object, an array, or a whole form node can cause your component to re-render far more often than needed.&lt;/p&gt;

&lt;p&gt;Bad example — watching the entire array:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;fieldGroupsArray&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useWatch&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;fieldGroupsArray&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// ❌ triggers re-render whenever anything changes in the array&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Better — watch only what you need:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;conditionalValue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useWatch&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;fieldGroupsArray.0.conditionalField&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// ✅ only reacts to this field&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;watch()&lt;/code&gt; re-renders the form where useForm() lives&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;useWatch()&lt;/code&gt; re-renders only the component calling it&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Use the second option for large form structures or repeated field groups. Your CPU will thank you.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Subscribing to formState can be expensive
&lt;/h3&gt;

&lt;p&gt;Accessing formState is powerful, but it has consequences. Some values trigger re-renders more often than others:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;dirtyFields&lt;/code&gt; updates on every change while typing → constant re-renders&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;touchedFields&lt;/code&gt; updates when a user focuses on the fields&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;errors&lt;/code&gt; changes when validation runs. Not a problem unless your validation runs endlessly&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Access only what you need. If you destructure everything because of "why not"—you might introduce performance issues blindly.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. When using Zod with dynamic fields, be cautious with &lt;code&gt;shouldUnregister&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Like me, if you’re a user of &lt;a href="https://zod.dev/api" rel="noopener noreferrer"&gt;Zod&lt;/a&gt; + RHF's dynamic conditional fields, think twice before enabling:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="nf"&gt;useForm&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;shouldUnregister&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="c1"&gt;// ⚠️ Caution&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Unregistered fields get completely removed from the form state, meaning you may lose default values that are still relevant for validation. This can lead to unexpected Zod validation failures, especially when showing/hiding fields conditionally.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;shouldUnregister&lt;/code&gt; flag immediately removes fields from RHF's internal state &lt;strong&gt;if it is not &lt;code&gt;register&lt;/code&gt;ed to any form input&lt;/strong&gt;. In dynamic schemas, keeping fields registered helps preserve data consistency.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. About using &lt;code&gt;&amp;lt;Controller&amp;gt;&lt;/code&gt; / &lt;code&gt;useController()&lt;/code&gt; when the standard &lt;code&gt;register()&lt;/code&gt; isn't enough
&lt;/h3&gt;

&lt;p&gt;Scenarios  where it is suitable:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;External UI libraries with no direct &lt;code&gt;ref&lt;/code&gt;, &lt;code&gt;value&lt;/code&gt;, or &lt;code&gt;onChange&lt;/code&gt; props exposed.&lt;/li&gt;
&lt;li&gt;Controlled inputs (e.g. Chakra UI &lt;code&gt;&amp;lt;Select /&amp;gt;&lt;/code&gt;) which possess their own separate internal state&lt;/li&gt;
&lt;li&gt;Complex custom components where you want granular control over which elements receive &lt;code&gt;{...field}&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// You may bind only &amp;lt;input&amp;gt; to form state instead of rerendering label + error&lt;/span&gt;
&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;CustomField&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;label&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Username&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;label&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;input&lt;/span&gt; &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;field&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt; &lt;span class="na"&gt;role&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"alert"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;errorMessage&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;CustomField&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This reduces noise, unnecessary renders, and keeps the field logic predictable.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping Up
&lt;/h2&gt;

&lt;p&gt;Not all of this may be new to you — maybe you nodded through every section, maybe some of it made you open your project and fix things immediately. Either way, if we both improved our understanding today, that’s already a win.&lt;/p&gt;

&lt;p&gt;Feel free to drop suggestions, corrections, or even healthy criticism in the comments.&lt;/p&gt;

&lt;p&gt;More experiments coming soon 😉&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>tutorial</category>
      <category>react</category>
      <category>performance</category>
    </item>
    <item>
      <title>Building forms using React Hook Form</title>
      <dc:creator>Dhokia Rinidh</dc:creator>
      <pubDate>Fri, 21 Nov 2025 18:35:28 +0000</pubDate>
      <link>https://forem.com/rinidh/building-forms-using-react-hook-form-d48</link>
      <guid>https://forem.com/rinidh/building-forms-using-react-hook-form-d48</guid>
      <description>&lt;p&gt;Hey folks!&lt;br&gt;&lt;br&gt;
While taking my online React course, I quickly discovered something: &lt;strong&gt;forms are everywhere&lt;/strong&gt;. Whether you’re buying groceries online, booking a table, signing in, paying fees, or typing questionable prompts into an AI model at 2 AM — you’re dealing with forms.&lt;/p&gt;

&lt;p&gt;Since I wanted my portfolio to look a little less “junior developer on day 3,” I decided to learn a solid form library alongside React. The first one on my list: &lt;strong&gt;&lt;a href="https://react-hook-form.com/" rel="noopener noreferrer"&gt;React Hook Form (RHF)&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;After going through the docs and doing a healthy amount of trial-and-error (emphasis on &lt;em&gt;error&lt;/em&gt;), here are some useful insights I picked up. Hopefully they help you skip a few of my mistakes.&lt;/p&gt;


&lt;h2&gt;
  
  
  Lessons Learned (a.k.a “Things I Wish Someone Told Me Earlier”)
&lt;/h2&gt;
&lt;h3&gt;
  
  
  1. &lt;code&gt;getValues()&lt;/code&gt; gives you a &lt;em&gt;snapshot&lt;/em&gt;, not a subscription
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;getValues()&lt;/code&gt; returns the current form data &lt;strong&gt;at the exact moment you call it&lt;/strong&gt;.&lt;br&gt;&lt;br&gt;
Use it in:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;event handlers
&lt;/li&gt;
&lt;li&gt;async functions
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;useEffect()&lt;/code&gt; callbacks
&lt;/li&gt;
&lt;li&gt;anywhere that gets triggered by something happening&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Just don’t expect it to magically stay updated. It’s a snapshot, not a live feed.&lt;/p&gt;
&lt;h3&gt;
  
  
  2. &lt;code&gt;watch()&lt;/code&gt; gives you real-time updates
&lt;/h3&gt;

&lt;p&gt;If you need a piece of form data &lt;strong&gt;that always stays in sync&lt;/strong&gt;, use &lt;code&gt;watch()&lt;/code&gt;.&lt;br&gt;&lt;br&gt;
It re-renders your component whenever those watched fields change. Perfect for features like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;showing live previews
&lt;/li&gt;
&lt;li&gt;enabling/disabling buttons
&lt;/li&gt;
&lt;li&gt;updating UI based on input
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Just remember: watching many fields can cause extra re-renders, so use it intentionally.&lt;/p&gt;
&lt;h3&gt;
  
  
  3. Handling errors the proper way
&lt;/h3&gt;

&lt;p&gt;Form errors can be accessed in two main ways:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;by inspecting &lt;code&gt;formState.errors&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;by using the second callback of &lt;code&gt;handleSubmit(onValid, onError)&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Both are useful, depending on whether you want to react to errors &lt;em&gt;during&lt;/em&gt; submission or check them &lt;em&gt;after&lt;/em&gt; validation.&lt;/p&gt;
&lt;h3&gt;
  
  
  4. Custom validators can be stacked (and async!)
&lt;/h3&gt;

&lt;p&gt;When using the &lt;code&gt;validate&lt;/code&gt; option inside &lt;code&gt;register()&lt;/code&gt;:&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;validate&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;validator1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Must be longer than 3 characters&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;validator2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;checkUsername&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;define multiple validator functions&lt;/li&gt;
&lt;li&gt;return true (valid) or a string (error message)&lt;/li&gt;
&lt;li&gt;even write async validators that call APIs or servers&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;RHF will run them all and aggregate the results.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. &lt;code&gt;reset()&lt;/code&gt; behavior depends on whether defaultValues exists
&lt;/h3&gt;

&lt;p&gt;If you did not pass defaultValues to useForm(), then calling:&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="nf"&gt;reset&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="na"&gt;firstName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;John&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;will update both the current values and the internal “default values”.&lt;/p&gt;

&lt;p&gt;If you did specify defaultValues, you can still override them by intentionally passing the values option:&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="nf"&gt;reset&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;values&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;firstName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;John&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This makes that object the new default state of your form.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;These are just a few tips that helped me understand React Hook Form better as a beginner. The library is incredibly lightweight, ergonomic, and fast — once you understand what each function is doing behind the scenes.&lt;/p&gt;

&lt;p&gt;If you spot anything interesting or want to add your own insights, feel free to drop a comment. And don’t worry, more posts are on the way (yes, even the embarrassing discoveries).&lt;/p&gt;

&lt;p&gt;Thanks for reading — and happy form-building!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>react</category>
      <category>forms</category>
    </item>
    <item>
      <title>Content consumption: Real world Development vs Big Tech Hype</title>
      <dc:creator>Dhokia Rinidh</dc:creator>
      <pubDate>Fri, 04 Jul 2025 19:26:07 +0000</pubDate>
      <link>https://forem.com/rinidh/content-consumption-real-world-development-vs-big-tech-hype-k35</link>
      <guid>https://forem.com/rinidh/content-consumption-real-world-development-vs-big-tech-hype-k35</guid>
      <description>&lt;h3&gt;
  
  
  Intro
&lt;/h3&gt;

&lt;p&gt;I would like to share my thoughts on a burning topic amongst most beginner-level engineers today. Most content these days creates excitement basing on FAANG companies (where one may never work, or need to work), cutting-edge frameworks (which one may never leverage / need to leverage), CS heavy content (for large scale apps), brain-boggling algorithms etc. But some of us really don’t need to wreck our minds to know about such things, at least not most of them if we are to thrive.&lt;/p&gt;

&lt;h3&gt;
  
  
  Confusion &amp;amp; Burnout
&lt;/h3&gt;

&lt;p&gt;I know you have heard about the “imposter syndrome” which is a mandatory stage in the life of every developer. Bleeding-edge tech is released almost daily and thanks to our brain—which is not an input box to feed info into easily—cannot become a legendary coder by switching gears all the time. It has to go slow, enjoy the goodness of specialization, and leverage it to better solve real-world problems.&lt;/p&gt;

&lt;p&gt;Emerging developers often keep feeling dissatisfied even with their excellent portfolio just because it still uses older tech stacks 😢 hence leading to learning burnout and decision paralysis as well on whether the career is even meant for them. Specialization and focus is key 🔑 😉&lt;/p&gt;

&lt;h3&gt;
  
  
  What SMEs care about
&lt;/h3&gt;

&lt;p&gt;Most of them always prioritize more maintainable code over complicated new tech stacks, simplicity &amp;amp; reliability of code over “coolness” of the framework, and pocket-friendly approaches that keep consumer comfort first.&lt;/p&gt;

&lt;p&gt;I am based in Uganda, East Africa, and I made a big mistake recently of creating a highly complex React-ChakraUI-based web application for a firm that simply needed a good hero-section for advertisement, a decent collection of beautifully styled HTML pages with instant loading that worked on the poorest network &amp;amp; oldest low-end devices, and what I did was completely disappointing. I don’t completely blame the tech-hype for this.&lt;/p&gt;

&lt;h3&gt;
  
  
  Stay focused on your needs, not on trends!
&lt;/h3&gt;

&lt;p&gt;You need to know your exact market, actual skills that you will need the most and where to acquire them from. I personally avoid YouTube channels, blogs or newsletters emphasizing only on new tech (I don’t even understand well the jargon in it 😂). Rather, I follow up with &lt;a href="https://www.youtube.com/c/KevinPowell" rel="noopener noreferrer"&gt;people focused on real-world&lt;/a&gt; &lt;a href="https://www.youtube.com/c/AdrianTwarog" rel="noopener noreferrer"&gt;implementation of software skills&lt;/a&gt;, &lt;a href="https://dev.to/"&gt;great communities&lt;/a&gt;, articles on status of SMEs &amp;amp; startups and &lt;a href="https://www.freecodecamp.org/news/tag/projects/" rel="noopener noreferrer"&gt;project-based learning paths&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Outro
&lt;/h3&gt;

&lt;p&gt;I don’t criticize those acting contrary to the above terms. They may be fully focused on big tech standards &amp;amp; excellence in software development with the new tech. I just beseech you to understand your actual needs well. Updating yourself on modern trends occasionally is fine as these technologies are what come down to SMEs later on. It can also be quite motivating as well to see the future prospects of the industry you work in&lt;/p&gt;

&lt;p&gt;As usual, please feel free to criticize, appreciate or share what you think about this.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>learning</category>
      <category>career</category>
    </item>
    <item>
      <title>My Web Development Journey - The New Maze</title>
      <dc:creator>Dhokia Rinidh</dc:creator>
      <pubDate>Fri, 27 Jun 2025 18:59:12 +0000</pubDate>
      <link>https://forem.com/rinidh/my-web-development-journey-the-new-maze-4j5f</link>
      <guid>https://forem.com/rinidh/my-web-development-journey-the-new-maze-4j5f</guid>
      <description>&lt;h2&gt;
  
  
  My Absence
&lt;/h2&gt;

&lt;p&gt;It’s been quite a while since &lt;a href="https://dev.to/rinidh/chronicles-of-supermarket-website-2-responsive-design-c0e"&gt;I last posted&lt;/a&gt; on DEV or any tech community. It wasn’t a vacation, and I definitely didn’t plan to ghost all the awesome, collaborative folks here. The truth is—I hit a serious wall. A full-on maze of confusion that stalled my workflow.&lt;br&gt;
I used to think going the self-taught route in web development was the ultimate shortcut for beginners. No degrees—just online resources, free courses, and a bit of hustling. Sounded like the magic formula. Well, yes..., but not entirely.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Realized
&lt;/h2&gt;

&lt;p&gt;Unless you’ve got endless hours to figure out what to learn, the stamina to dive deep, and a secret potion to fight off imposter syndrome, self-teaching can hit really really hard.&lt;br&gt;
Most of us are juggling jobs, studies, life... and trying to stay motivated feels like carrying water uphill in a basket. I’m working 8–9 hours a day, trying to protect my health and make time for hobbies. That’s when I made a tough call: go back to school for a degree. (Yeah, I cried a little too 😢 but the fog started lifting.)&lt;br&gt;
But why? Get direct access to tutors, a structured curriculum, and a community to grow with. But wait—in a discourse with &lt;a href="https://topmate.io/satish_shriwas" rel="noopener noreferrer"&gt;a great Uber engineer&lt;/a&gt;, I confirmed that even with a degree, I’ll still need to do a ton of self-learning, build projects, and contribute before I can really collaborate.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Fear Factor
&lt;/h2&gt;

&lt;p&gt;Here’s the kicker: I was afraid my online certifications wouldn’t hold much weight in interviews. It’s a huge concern for self-taught devs. That’s why I started looking for credible, recognized certifications alongside a degree—something with real validation behind it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Plan for the Game Ahead
&lt;/h2&gt;

&lt;p&gt;So here’s where I’m at: I’m grinding toward the Meta Front-End Developer certification and pursuing a legit Computer Science degree to build credibility. But even with that, success means sticking to the grind—researching, pushing through bugs, building that portfolio from the ground up.&lt;br&gt;
As usual, feel free to comment, criticize &amp;amp; share your opinion because in this maze, there’s no single path. Just your hustle, your code, and your courage.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>webdev</category>
      <category>career</category>
    </item>
    <item>
      <title>Chronicles of Supermarket website #2: responsive design</title>
      <dc:creator>Dhokia Rinidh</dc:creator>
      <pubDate>Fri, 31 Jan 2025 17:23:14 +0000</pubDate>
      <link>https://forem.com/rinidh/chronicles-of-supermarket-website-2-responsive-design-c0e</link>
      <guid>https://forem.com/rinidh/chronicles-of-supermarket-website-2-responsive-design-c0e</guid>
      <description>&lt;h3&gt;
  
  
  From #1 and moving ahead:
&lt;/h3&gt;

&lt;p&gt;I &lt;a href="https://dev.to/rinidh/chronicles-of-supermarket-website-1c9"&gt;previously posted&lt;/a&gt; my journey into building a simple (no fuss or perplexity; for beginners) &lt;a href="https://chikubu-shoppers-rinidhs-projects.vercel.app/" rel="noopener noreferrer"&gt;supermarket website&lt;/a&gt;. I had only used HTML &amp;amp; CSS to construct a straight forward, unornamented website. As per the modern craze in web development, all websites should appear dazzling on however small of a screen it may be viewed. I therefore persuaded my brain to review my code and add a couple of media queries as well as beautify the previous code to achieve my goals.&lt;/p&gt;

&lt;p&gt;However, this section also never went by without upskilling my brain-content.&lt;/p&gt;

&lt;h3&gt;
  
  
  Key lessons
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Prefer using absolute units eg &lt;code&gt;cm&lt;/code&gt;, &lt;code&gt;mm&lt;/code&gt;, &lt;code&gt;in&lt;/code&gt;, &lt;code&gt;pt&lt;/code&gt;, &lt;code&gt;px&lt;/code&gt; etc. for content to be printed to hardcopy. Avoid them to the most in responsive layouts.&lt;/li&gt;
&lt;li&gt;Try to avoid setting fixed &lt;code&gt;width&lt;/code&gt; in &lt;code&gt;px&lt;/code&gt;, &lt;code&gt;in&lt;/code&gt; etc. especially for large elements e.g. large banner images, &lt;code&gt;&amp;lt;section&amp;gt;&lt;/code&gt;s or whatever forces a user to &lt;strong&gt;scroll horizontally&lt;/strong&gt;. It may be tempting to initially satisfy your design by this, but always remember to replace with &lt;a href="https://developer.mozilla.org/en-US/docs/Learn_web_development/Core/Styling_basics/Values_and_units#lengths" rel="noopener noreferrer"&gt;relative units&lt;/a&gt; such as &lt;code&gt;---%&lt;/code&gt;, &lt;code&gt;rem&lt;/code&gt;, &lt;code&gt;em&lt;/code&gt;, &lt;code&gt;vw&lt;/code&gt;, &lt;code&gt;vh&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Either set specific height &amp;amp; width (in relative or absolute units) to the parent &lt;code&gt;flex_container&lt;/code&gt;, hence the &lt;code&gt;nested_div&lt;/code&gt;s occupy space variably (I call this technique ‘fixed-container’), or height and width of containers as &lt;code&gt;auto&lt;/code&gt; (flexible upto even zero) and hence fixed sizes of &lt;code&gt;nested_div&lt;/code&gt;s determine the resultant size of the &lt;code&gt;flex_container&lt;/code&gt; (I call this techique ‘fixed-nested-divs’). &lt;strong&gt;Most used is ‘fixed-container’.&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Always design mobile-first (unless majority of audience are desktop users). Write default styles for small screens first, and use media queries for larger screens. Avoid extra fluff in headers, navbars… for mobile screens. Use media queries to modify very few properties for larger screen sizes (&lt;code&gt;@media only screen and (min-width: 600px)&lt;/code&gt; applies styles for screens’ width of 600px and above).&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;(min-device-width: 400px)&lt;/code&gt; instead of &lt;code&gt;(min-width: 400px)&lt;/code&gt; to check for device actual screen size instead of web document size. Styles under this are not affected by changing window size or by rendering another html file inside an html file by&lt;code&gt;&amp;lt;iframe&amp;gt;&lt;/code&gt;s.&lt;/li&gt;
&lt;li&gt;Use different images on different screen sizes using &lt;code&gt;&amp;lt;picture&amp;gt;&lt;/code&gt;, more so the same image but of different resolutions as well ot reduce load bundle e.g. can use &lt;code&gt;url('../assets/flowers-lg')&lt;/code&gt; on large screens and &lt;code&gt;url('../assets/flowers-sm')&lt;/code&gt; on phones.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;--em&lt;/code&gt; when set on &lt;code&gt;font-size&lt;/code&gt; means relative to &lt;strong&gt;parent element&lt;/strong&gt; while &lt;code&gt;em&lt;/code&gt; in other properties s e.g. &lt;code&gt;width: 3em&lt;/code&gt; means relative to font-size of &lt;strong&gt;current element.&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;em&lt;/code&gt; when you always want text to be certain size according to its &lt;strong&gt;immediate parent&lt;/strong&gt;. Use &lt;code&gt;rem&lt;/code&gt; in deep nesting scenarios when you want the size relative to fontsize of the &lt;strong&gt;root element&lt;/strong&gt; (stays unchanged).&lt;/li&gt;
&lt;li&gt;Properties &lt;strong&gt;commonly&lt;/strong&gt; set with &lt;code&gt;em&lt;/code&gt; and &lt;code&gt;rem&lt;/code&gt;: font-size, margin &amp;amp; padding.&lt;/li&gt;
&lt;li&gt;Properties &lt;strong&gt;commonly&lt;/strong&gt; set with &lt;code&gt;%&lt;/code&gt;, &lt;code&gt;vw&lt;/code&gt; and &lt;code&gt;vh&lt;/code&gt;: width, height, postioning (fixed &amp;amp; absolute), flex-basis, margin and padding.&lt;/li&gt;
&lt;li&gt;Classifications of design technqiues (can use any one or combine):

&lt;ul&gt;
&lt;li&gt;Link diff stylesheets OR&lt;/li&gt;
&lt;li&gt;Media queries within CSS OR&lt;/li&gt;
&lt;li&gt;Flexible grids &amp;amp; css &lt;code&gt;column&lt;/code&gt; + Relative values &amp;amp; &lt;code&gt;calc()&lt;/code&gt; + min &amp;amp; max&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;Please don’t hesitate to criticize and suggest edits 😘&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>webdev</category>
      <category>tutorial</category>
      <category>discuss</category>
    </item>
    <item>
      <title>Regular this, Arrow this (Tersely bulleted)</title>
      <dc:creator>Dhokia Rinidh</dc:creator>
      <pubDate>Wed, 22 Jan 2025 19:44:37 +0000</pubDate>
      <link>https://forem.com/rinidh/regular-this-arrow-this-tersely-bulleted-1fo5</link>
      <guid>https://forem.com/rinidh/regular-this-arrow-this-tersely-bulleted-1fo5</guid>
      <description>&lt;p&gt;Hello code-mates, ever since I learnt about &lt;code&gt;this&lt;/code&gt; in Javascript a year ago, I had never fully felt mentally confident that I can interpret, analyse and refactor complicated scenarios where &lt;code&gt;this&lt;/code&gt; is used. I therefore made a small cheatsheet-like summary to always help me get the immediate context &amp;amp; idea, especially when I am rushing through documentations or others’ code, and obviously infiltrate well later.&lt;/p&gt;

&lt;p&gt;Here are a few bullets I always find handy in relation to &lt;code&gt;this&lt;/code&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;All regular functions (&lt;code&gt;function myFunction() {}&lt;/code&gt;) always have their &lt;code&gt;this&lt;/code&gt; as the global &lt;code&gt;window&lt;/code&gt; object (in browsers) or &lt;code&gt;global&lt;/code&gt; object (in Node JS), UNLESS it is called in a different context:

&lt;ul&gt;
&lt;li&gt;As a method of an object.&lt;/li&gt;
&lt;li&gt;Explicitly bound by &lt;code&gt;.bind()&lt;/code&gt;, &lt;code&gt;.call()&lt;/code&gt; or &lt;code&gt;.apply()&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Regular functions have to be explicitly bound with a &lt;code&gt;this&lt;/code&gt; value while arrow functions  (&lt;code&gt;() =&amp;gt; {}&lt;/code&gt;) automatically get their &lt;code&gt;this&lt;/code&gt; from the immediate enclosing parent-function (lexical scope).&lt;/li&gt;

&lt;li&gt;The lexical/enclosing scope in which an arrow function is actually running is the immediate parent REGULAR function, even though it is inside an object’s  method.&lt;/li&gt;

&lt;li&gt;The &lt;code&gt;this&lt;/code&gt; value of arrow functions (got at time of creation) is unchangeable while that of regular functions is changeable (&lt;code&gt;.bind()&lt;/code&gt;, &lt;code&gt;.call()&lt;/code&gt; etc.)&lt;/li&gt;

&lt;li&gt;Unlike methods of object literals (&lt;code&gt;const obj = {...}&lt;/code&gt;), functions defined as methods of classes, Event though regular or arrow, their &lt;code&gt;this&lt;/code&gt; is always the object instance created (&lt;code&gt;new MyClass()&lt;/code&gt;)&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;Please feel free to suggest edits, add more bullets, or even criticize me on any blunders. I always welcome an opportunity to learn from excellent programmers like you! ☺️ 💛&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>learning</category>
      <category>coding</category>
    </item>
    <item>
      <title>Chronicles of Supermarket website #1: HTML &amp; CSS</title>
      <dc:creator>Dhokia Rinidh</dc:creator>
      <pubDate>Wed, 15 Jan 2025 19:29:54 +0000</pubDate>
      <link>https://forem.com/rinidh/chronicles-of-supermarket-website-1c9</link>
      <guid>https://forem.com/rinidh/chronicles-of-supermarket-website-1c9</guid>
      <description>&lt;h3&gt;
  
  
  My mistake
&lt;/h3&gt;

&lt;p&gt;In the previous year, I learn a lot but in haste as well as in vain. I didn’t realize how and when the &lt;a href="https://en.wikipedia.org/wiki/Impostor_syndrome" rel="noopener noreferrer"&gt;imposter syndrome&lt;/a&gt; sieged my determined mindset. It was indeed a big blunder to mock and neglect learning the fundamentals — HTML, CSS &amp;amp; vanilla JS); I never considered advice from great youtubers, so I it took me months of physical trial to realize this on my own.&lt;/p&gt;

&lt;h3&gt;
  
  
  The new site
&lt;/h3&gt;

&lt;p&gt;Let bygones be bygones. This year I started afresh, learning the basic building blocks of web development with a rather cautious mindset. Starting up with plain HTML5 and CSS3, I have built a mini supermarket app with only these two technologies. Apologies in advance if your eyes pain and you cringe seeing so much newbie code; I tried to keep it as simple as possible. You can view the production site &lt;a href="https://chikubu-shoppers.vercel.app/" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;⚠️ I have used some names and terms in the local language of my area of residence&lt;/p&gt;

&lt;p&gt;Having accomplished this first stage, without any responsive design, any framework, any javascript, or any complicated sauce in this simple cookout, just with html and css, I still learnt quite a few interesting facts I want to share.&lt;/p&gt;

&lt;h3&gt;
  
  
  Key lessons
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Set a specific height and width on a div and &lt;code&gt;overflow-y: auto/scroll&lt;/code&gt;to allow scrolling inside the div, if its content is larger/more than its size&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;margin: auto&lt;/code&gt; makes a div centered in its parent. To horizontally center a child div in its parent, use &lt;code&gt;margin-left; margin-right: auto&lt;/code&gt;. Similarly for vertical only centering, &lt;code&gt;margin-top; margin-bottom: auto&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Attributes you will use everytime with &lt;code&gt;&amp;lt;input&amp;gt;&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt;
    &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"for ref to label tag"&lt;/span&gt;
    &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"for ref in js code"&lt;/span&gt;
    &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"to be sent to server"&lt;/span&gt;
    &lt;span class="na"&gt;title=&lt;/span&gt;&lt;span class="s"&gt;"global att, text shown when pointer hovers over elem"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Place &lt;code&gt;&amp;lt;input&amp;gt;&lt;/code&gt; inside &lt;code&gt;&amp;lt;label&amp;gt;&lt;/code&gt; tags to automatically relate to the label without using the same &lt;code&gt;id&lt;/code&gt; with &lt;code&gt;for&lt;/code&gt; attribute&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;label&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;label&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;textarea&lt;/span&gt; &lt;span class="na"&gt;cols=&lt;/span&gt;&lt;span class="s"&gt;"35"&lt;/span&gt; &lt;span class="na"&gt;rows=&lt;/span&gt;&lt;span class="s"&gt;"10"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;

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

&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  My Request
&lt;/h3&gt;

&lt;p&gt;That’s a few of them. It’s just the beginning of this marathon. Please feel free to admire or roast (criticize) me on any blunders, I am eager to see your suggestions, as Industry experts, on how I can improve this site, its design, its implementation etc.&lt;/p&gt;

&lt;p&gt;Lots of Love, &lt;/p&gt;

&lt;p&gt;Rinidh 😉&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>webdev</category>
      <category>tutorial</category>
      <category>discuss</category>
    </item>
    <item>
      <title>I am productive, are you?</title>
      <dc:creator>Dhokia Rinidh</dc:creator>
      <pubDate>Wed, 25 Dec 2024 19:36:46 +0000</pubDate>
      <link>https://forem.com/rinidh/i-am-productive-are-you-325a</link>
      <guid>https://forem.com/rinidh/i-am-productive-are-you-325a</guid>
      <description>&lt;p&gt;Hello guys, how is the marathon going. Running in the fast paced world today, we realize that our brain is surely a powerful CPU but a weaker RAM. Taking out the fancy words, I mean that amidst very many daily tasks and to-dos, we can’t accurately remember and coordinate all, but surely, with focus on only one at a time, accomplish tasks like a expert.&lt;/p&gt;

&lt;p&gt;I am a beginner, and after receiving loving support and advice from a number of senior developers (like you), I have ended up with a simple, beginner-friendly toolset / system for productivity, that I want to share today. To be honest, each has a different mindset, habits, likes, hates, preferences etc. but I feel this will help uplift newbies like me.&lt;/p&gt;

&lt;p&gt;I decided to organize my information in 3 levels, according to the urgency of its need:&lt;/p&gt;

&lt;h3&gt;
  
  
  Level 1 : Immediate To-dos
&lt;/h3&gt;

&lt;p&gt;Only store information that you are going to use at a maximum duration of tomorrow. I formerly used simple windows sticky notes, and they would be great up to the end of my career unless they had very small, hard-to-read letters, which are only customizable from general font settings of entire windows system.&lt;/p&gt;

&lt;p&gt;I decided to stick with the desktop app of Google Keep (as I am a rising fan of Google Ecosystem). This also ensures automatic frequent backup to the cloud. I usually put information to help me start of immediately on the project the next day e.g. “style the banner on about-us page”&lt;/p&gt;

&lt;h3&gt;
  
  
  Level 2 : Tasks
&lt;/h3&gt;

&lt;p&gt;Include information that you will be working on for the next 3 days, week or even few more weeks depending on your preference. I use Notion as it is great, especially when you will work with teams in the future. I may include information such as “Make html-css only website, max time: 12/01/2025”&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fof82bv3dzxdm2hsfcxk1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fof82bv3dzxdm2hsfcxk1.png" alt="Productivity of a beginner" width="800" height="428"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Level 3 : Plan (Long Term)
&lt;/h3&gt;

&lt;p&gt;Still using Notion, I set up a long term rough-copy list of what I have to learn, and keep adding to it whenever I find new technologies I need to learn, as well as which projects to make and when. This is crucial as it gives you a bird’s eye, or rather an eagle’s eye view of your progress and motivates you to push faster as you see the road ahead. As you keep completing one by one, keep transferring the current item to the “Tasks” list above.&lt;/p&gt;

&lt;p&gt;I guess you might have noticed the toggle heading of “Routine” in the above photo. I realised that reading articles, documentation and even (sensible) social media posts is mandatory if you are succeed as a developer. I therefore drafted a timetable to follow for reading, taking out at least 30 to 45 minutes of my daily time&lt;/p&gt;

&lt;p&gt;That’s it guys. &lt;strong&gt;Please do share what you think&lt;/strong&gt; I and other beginner developers can include and exclude in this simple work plan. I never wanted to initially complicate my work with feature-rich apps. This also widened my thinking / creativity and proves to me the use of efficient, more personalized system of work&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>discuss</category>
    </item>
    <item>
      <title>New to web dev like me?</title>
      <dc:creator>Dhokia Rinidh</dc:creator>
      <pubDate>Sun, 15 Dec 2024 19:35:55 +0000</pubDate>
      <link>https://forem.com/rinidh/new-to-web-dev-like-me-2jaa</link>
      <guid>https://forem.com/rinidh/new-to-web-dev-like-me-2jaa</guid>
      <description>&lt;p&gt;Hello enthusiastic developers,&lt;/p&gt;

&lt;p&gt;I am Rinidh Dhokia, a self-learning web developer based in Uganda, with already about year of study &amp;amp; research, thanks to the widened world web, or rather world wide web 😉.&lt;/p&gt;

&lt;p&gt;It's true that everything today is indeed available on the web. The problem is just about the way to discover &amp;amp; exploit these resources instead of spending thousands of dollars at colleges, unless you want to  peruse through upto a doctorate.&lt;/p&gt;

&lt;p&gt;It's going to be an interesting journey at this platform. I highly urge you to follow up with me, as I learnt that collaboration is key. No matter how good your skillset, if you can't work together with a team of friends to make the best out of it, it's not marketable.&lt;/p&gt;

&lt;p&gt;Thank you...&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>developer</category>
      <category>watercooler</category>
    </item>
  </channel>
</rss>
