<?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: Akshay S</title>
    <description>The latest articles on DEV Community by Akshay S (@akshaysrepo).</description>
    <link>https://dev.to/akshaysrepo</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%2F382985%2F25e91f49-1c87-4672-a460-ac7f6eb91094.jpg</url>
      <title>DEV Community: Akshay S</title>
      <link>https://dev.to/akshaysrepo</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/akshaysrepo"/>
    <language>en</language>
    <item>
      <title>Why Writing Your Thoughts Down Doesn’t Stop Overthinking (And What Actually Does)</title>
      <dc:creator>Akshay S</dc:creator>
      <pubDate>Wed, 14 Jan 2026 04:48:15 +0000</pubDate>
      <link>https://dev.to/akshaysrepo/why-writing-your-thoughts-down-doesnt-stop-overthinking-and-what-actually-does-1el3</link>
      <guid>https://dev.to/akshaysrepo/why-writing-your-thoughts-down-doesnt-stop-overthinking-and-what-actually-does-1el3</guid>
      <description>&lt;p&gt;Most people try to deal with overthinking by writing things down.&lt;/p&gt;

&lt;p&gt;They open Google Docs.&lt;br&gt;
They use Notion.&lt;br&gt;
They start journaling.&lt;/p&gt;

&lt;p&gt;It feels productive. But the thought is still there.&lt;/p&gt;

&lt;p&gt;The same worry comes back.&lt;br&gt;
The same fear repeats.&lt;br&gt;
The same story plays every day.&lt;/p&gt;

&lt;p&gt;This happens because &lt;strong&gt;writing does not process a thought. It only stores it.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Your brain doesn’t care that the words are on a screen.&lt;br&gt;
If the emotional loop is unresolved, it keeps running.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Writing Alone Fails
&lt;/h2&gt;

&lt;p&gt;Overthinking is not caused by too many thoughts.&lt;/p&gt;

&lt;p&gt;It’s caused by &lt;strong&gt;unprocessed uncertainty&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;When the brain detects a possible threat — social, emotional, financial, relational — it tries to solve it by replaying it.&lt;/p&gt;

&lt;p&gt;This loop continues until one of two things happens:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The brain gets clarity&lt;/li&gt;
&lt;li&gt;The brain gets exhausted&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Writing without structure gives neither.&lt;br&gt;
You just re-read the same fear in different words.&lt;/p&gt;

&lt;p&gt;That’s why journaling often feels good in the moment, then useless 30 minutes later.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Psychologists Actually Stop Thought Loops
&lt;/h2&gt;

&lt;p&gt;When someone goes to therapy, a psychologist doesn’t say:&lt;/p&gt;

&lt;p&gt;“Write it down and move on.”&lt;/p&gt;

&lt;p&gt;They walk the person through a &lt;strong&gt;structured cognitive process&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This comes from Cognitive Behavioral Therapy (CBT), one of the most scientifically supported methods for treating anxiety, depression, and rumination.&lt;/p&gt;

&lt;p&gt;The flow looks like this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What exactly is the thought?&lt;/li&gt;
&lt;li&gt;What am I assuming?&lt;/li&gt;
&lt;li&gt;Is this a fact or a fear?&lt;/li&gt;
&lt;li&gt;What evidence supports it?&lt;/li&gt;
&lt;li&gt;What evidence contradicts it?&lt;/li&gt;
&lt;li&gt;What happens if I stop engaging with it?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This order matters.&lt;/p&gt;

&lt;p&gt;It forces the brain out of emotional reaction and into analytical reasoning.&lt;/p&gt;

&lt;p&gt;And when that happens, something important changes.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Moment the Brain Lets Go
&lt;/h2&gt;

&lt;p&gt;A looping thought feels dangerous.&lt;/p&gt;

&lt;p&gt;But when you slow it down and examine it, the brain often realizes:&lt;/p&gt;

&lt;p&gt;“This feels real… but it isn’t actually true.”&lt;/p&gt;

&lt;p&gt;That shift is not motivation.&lt;br&gt;
It’s not positive thinking.&lt;br&gt;
It’s &lt;strong&gt;threat resolution&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Once the brain decides the threat is false or exaggerated, it stops spending energy on it.&lt;/p&gt;

&lt;p&gt;That’s why people feel lighter after a good therapy session.&lt;br&gt;
The thought didn’t disappear — it lost its emotional power.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Overthinking Is a System Problem
&lt;/h2&gt;

&lt;p&gt;Overthinking is not a personality flaw.&lt;br&gt;
It’s a &lt;strong&gt;processing failure&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Your brain is running the same unfinished task over and over because it doesn’t have a way to close it.&lt;/p&gt;

&lt;p&gt;Google Docs and Notion are great for writing.&lt;br&gt;
They are terrible for thinking.&lt;/p&gt;

&lt;p&gt;They don’t ask questions.&lt;br&gt;
They don’t challenge assumptions.&lt;br&gt;
They don’t separate fear from fact.&lt;/p&gt;

&lt;p&gt;They just record whatever your anxiety says.&lt;/p&gt;

&lt;h2&gt;
  
  
  Processing vs Dumping
&lt;/h2&gt;

&lt;p&gt;There’s a big difference between:&lt;/p&gt;

&lt;p&gt;“I wrote it down.”&lt;/p&gt;

&lt;p&gt;and&lt;/p&gt;

&lt;p&gt;“I worked through it.”&lt;/p&gt;

&lt;p&gt;Writing is a memory system.&lt;br&gt;
Processing is a resolution system.&lt;/p&gt;

&lt;p&gt;One stores the problem.&lt;br&gt;
The other ends the loop.&lt;/p&gt;

&lt;p&gt;That’s the real difference between journaling and therapy.&lt;/p&gt;

&lt;p&gt;One collects thoughts.&lt;br&gt;
The other dismantles them.&lt;/p&gt;

&lt;h2&gt;
  
  
  A Better Way to Process Thoughts
&lt;/h2&gt;

&lt;p&gt;If you want to actually run your thoughts through this kind of structured psychological flow, tools like &lt;strong&gt;NoiseFilter&lt;/strong&gt; are being built to do exactly that — turning overthinking into a guided, step-by-step clarity process instead of a mental spiral.&lt;/p&gt;

&lt;p&gt;You can see how it works here:&lt;br&gt;
&lt;a href="https://www.noisefilter.app" rel="noopener noreferrer"&gt;https://www.noisefilter.app&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Thought
&lt;/h2&gt;

&lt;p&gt;If your mind keeps returning to the same worry, it’s not because you didn’t write it.&lt;/p&gt;

&lt;p&gt;It’s because the brain still thinks the threat is real.&lt;/p&gt;

&lt;p&gt;The moment you guide a thought through evidence, assumptions, and reality checks, it stops being dangerous.&lt;/p&gt;

&lt;p&gt;And dangerous thoughts are the only ones that loop.&lt;/p&gt;

&lt;p&gt;That’s the science behind mental relief.&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>mentalhealth</category>
      <category>discuss</category>
      <category>learning</category>
    </item>
    <item>
      <title>How I Fixed a Circular Dependency Bug in Redux Using dpdm</title>
      <dc:creator>Akshay S</dc:creator>
      <pubDate>Tue, 08 Oct 2024 16:01:48 +0000</pubDate>
      <link>https://dev.to/akshaysrepo/how-i-fixed-a-circular-dependency-bug-in-redux-using-dpdm-13ap</link>
      <guid>https://dev.to/akshaysrepo/how-i-fixed-a-circular-dependency-bug-in-redux-using-dpdm-13ap</guid>
      <description>&lt;h3&gt;
  
  
  Breaking the Circle of Confusion: A Redux Circular Dependency Journey
&lt;/h3&gt;

&lt;p&gt;Recently, I stumbled across a bug in my Redux codebase that left me scratching my head. If you've ever felt that sudden wave of confusion when the test suite throws an error that makes no sense, you’ll know the feeling. Here's what happened and how I eventually found (and fixed) the issue.&lt;/p&gt;

&lt;h3&gt;
  
  
  What on Earth is a Circular Dependency?
&lt;/h3&gt;

&lt;p&gt;A &lt;strong&gt;circular dependency&lt;/strong&gt; occurs when two or more modules depend on each other—directly or indirectly—creating an infinite loop in the dependency chain. In other words, it's like two friends saying, "You go first," but no one ever moves. In JavaScript, this can result in undefined modules or incomplete data, which leads to bugs that can be incredibly hard to trace.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Culprit: An Example
&lt;/h3&gt;

&lt;p&gt;Imagine two JavaScript files, &lt;code&gt;moduleA.js&lt;/code&gt; and &lt;code&gt;moduleB.js&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="c1"&gt;// moduleA.js&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;functionB&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;./moduleB.js&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="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;functionA&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;functionA called&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nf"&gt;functionB&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// moduleB.js&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;functionA&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;./moduleA.js&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="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;functionB&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;functionB called&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nf"&gt;functionA&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;Here, both modules depend on each other. When JavaScript tries to load them, it gets confused because neither can be fully loaded without the other being ready first. This leads to problems like undefined functions or incomplete modules—basically, a mess.&lt;/p&gt;

&lt;h3&gt;
  
  
  So, How Did I Find My Circular Dependency?
&lt;/h3&gt;

&lt;p&gt;Ah, the dreaded error that kicked off this adventure:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Error: `reducer` is a required argument, and must be a function or an object of functions that can be passed to combineReducers.
 ❯ Module.configureStore node_modules/@reduxjs/toolkit/src/configureStore.ts:98:11
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;My first reaction? &lt;em&gt;"Wait, what?!"&lt;/em&gt; — not my finest moment. I was sure my reducers were in place, so this error seemed out of nowhere. After some digging, I realized this wasn’t a missing reducer issue but a circular dependency sneaking into my Redux setup. Of course, figuring that out wasn't easy!&lt;/p&gt;

&lt;h3&gt;
  
  
  The Real Hero: &lt;code&gt;dpdm&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;That's when I found my savior: the npm package &lt;a href="https://www.npmjs.com/package/dpdm" rel="noopener noreferrer"&gt;&lt;code&gt;dpdm&lt;/code&gt;&lt;/a&gt;. This gem analyzes your dependency tree and shows you where those sneaky circular dependencies live. Running the following command gave me a clear view:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dpdm &lt;span class="nt"&gt;--no-warning&lt;/span&gt; &lt;span class="nt"&gt;--no-tree&lt;/span&gt; ./src/index.tsx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And voilà! Here’s a taste of what it found in my project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;• Circular Dependencies
  01) src/stores/store.ts -&amp;gt; src/stores/rootReducer.ts -&amp;gt; src/stores/slice/authSlice.ts -&amp;gt; src/utilities/api.ts
  02) src/stores/rootReducer.ts -&amp;gt; src/stores/slice/bookingSlice.ts -&amp;gt; src/hooks/redux.tsx -&amp;gt; src/stores/types.ts -&amp;gt; src/stores/setUpStore.ts
  03) src/stores/types.ts -&amp;gt; src/stores/setUpStore.ts
  ...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  The Fix: Refactoring Time!
&lt;/h3&gt;

&lt;p&gt;The report was clear: there were a bunch of circular dependencies in my Redux files, primarily in &lt;code&gt;store.ts&lt;/code&gt;, &lt;code&gt;rootReducer.ts&lt;/code&gt;, and some slices. After splitting up some of the logic, breaking down unnecessary dependencies, and refactoring the code, I finally got things back in order.&lt;/p&gt;

&lt;h3&gt;
  
  
  Lessons Learned
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Circular dependencies are sneaky&lt;/strong&gt;: They often don’t show up until runtime or during unit tests, making them hard to track down.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tools like &lt;code&gt;dpdm&lt;/code&gt; are lifesavers&lt;/strong&gt;: Don’t waste time manually searching through imports. Let tools do the heavy lifting.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Refactoring is your friend&lt;/strong&gt;: Sometimes circular dependencies are a sign of bad architecture. A good refactor not only fixes the immediate issue but also makes your codebase cleaner and more maintainable.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So, the next time you run into one of these pesky bugs, grab some coffee, have a laugh, and break that circle!&lt;/p&gt;

&lt;p&gt;Happy debugging! 😊&lt;/p&gt;

</description>
      <category>redux</category>
      <category>javascript</category>
      <category>npm</category>
      <category>dpdm</category>
    </item>
    <item>
      <title>Rotating Images with Node.js Made Easy: Automate BoreStuffs</title>
      <dc:creator>Akshay S</dc:creator>
      <pubDate>Wed, 27 Mar 2024 04:20:54 +0000</pubDate>
      <link>https://dev.to/akshaysrepo/rotating-images-with-nodejs-made-easy-automate-borestuffs-hph</link>
      <guid>https://dev.to/akshaysrepo/rotating-images-with-nodejs-made-easy-automate-borestuffs-hph</guid>
      <description>&lt;p&gt;Are you looking to automate the process of rotating images using Node.js? Look no further! In this guide, we'll walk through a simple script that utilizes the Jimp library to effortlessly rotate images.&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting Started
&lt;/h2&gt;

&lt;p&gt;First things first, let's ensure you have Node.js installed on your machine. If not, head over to &lt;a href="https://nodejs.org/"&gt;Node.js&lt;/a&gt; website and follow the installation instructions.&lt;/p&gt;

&lt;p&gt;Next, create a new directory for your project and initialize it with npm:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mkdir &lt;/span&gt;image-rotation
&lt;span class="nb"&gt;cd &lt;/span&gt;image-rotation
npm init &lt;span class="nt"&gt;-y&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will create a &lt;code&gt;package.json&lt;/code&gt; file where we'll manage our project dependencies.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Installing Dependencies&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We'll need two main dependencies for this project: Jimp for image processing and fs for file system operations. Let's install them:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;jimp fs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;The Code&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now, let's dive into the code. Below is a simplified version of a Node.js script that rotates images within a specified directory by 180 degrees:&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="c1"&gt;// Import required modules&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;Jimp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;jimp&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;fs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;fs&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Define the directory path where images are located&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;directoryPath&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Specify your directory path here&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;rotateDeg&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;180&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Define the rotation angle&lt;/span&gt;

&lt;span class="c1"&gt;// Function to get files in the directory&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;getTheFilesInTheDir&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;dir&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;callback&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;fs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;readdir&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;dir&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;function &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;files&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Unable to scan directory: &lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="nf"&gt;callback&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;getTheFilesInTheDir&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="nx"&gt;files&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
            &lt;span class="nf"&gt;callback&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;files&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;span class="c1"&gt;// Function to rotate an image&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;rotateImage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;filePath&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;Jimp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;read&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;filePath&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;image&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="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;RotatedImage:&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;filePath&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="nx"&gt;image&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;rotate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;180&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;filePath&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Rotate the image by 180 degrees&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Function to initiate the rotation process&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;initRotate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;async &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="nf"&gt;getTheFilesInTheDir&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;directoryPath&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;files&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="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Error:&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Files:&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;files&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;for &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;file&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nx"&gt;files&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;directoryPath&lt;/span&gt; &lt;span class="o"&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="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;file&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;ext&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;file&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;split&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="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;ext&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;ext&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;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;webp&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
                &lt;span class="c1"&gt;// Skip rotating WebP files, if any specific handling is required, add it here&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;rotateImage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Rotate non-WebP images&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;span class="c1"&gt;// Call the function to initiate rotation&lt;/span&gt;
&lt;span class="nf"&gt;initRotate&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;Explanation&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We start by importing necessary modules: &lt;code&gt;Jimp&lt;/code&gt; for image manipulation and &lt;code&gt;fs&lt;/code&gt; for file system operations.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;directoryPath&lt;/code&gt; variable holds the path to the directory containing the images to be rotated.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;getTheFilesInTheDir&lt;/code&gt; function reads the files in the specified directory.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;rotateImage&lt;/code&gt; function takes a file path, reads the image using Jimp, rotates it by 180 degrees, and saves it.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;initRotate&lt;/code&gt; function orchestrates the rotation process by getting the files in the directory and iterating through them to rotate each one.&lt;/li&gt;
&lt;li&gt;We check the file extension to skip rotating WebP images if present, but you can customize this behavior as needed.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;And that's it! You've just created a simple Node.js script to rotate images effortlessly. Feel free to modify the code according to your specific requirements and integrate it into your projects. Happy coding!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>node</category>
      <category>image</category>
      <category>automate</category>
    </item>
    <item>
      <title>Building Web Apps with React, WebAssembly, and Go</title>
      <dc:creator>Akshay S</dc:creator>
      <pubDate>Tue, 06 Feb 2024 13:31:09 +0000</pubDate>
      <link>https://dev.to/akshaysrepo/building-web-apps-with-react-webassembly-and-go-27f8</link>
      <guid>https://dev.to/akshaysrepo/building-web-apps-with-react-webassembly-and-go-27f8</guid>
      <description>&lt;h1&gt;
  
  
  &lt;strong&gt;Introduction&lt;/strong&gt;
&lt;/h1&gt;

&lt;p&gt;Hey folks! Welcome to this blog where we'll delve into the fascinating world of WebAssembly with React.js and Go Lang. But before we jump in, let's quickly demystify WebAssembly—what it is, why it's beneficial, where it finds its applications and how its work.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;What is WebAssembly (WASM)?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;WebAssembly is like the superhero of web development! It's a special kind of code that can run in modern web browsers. Think of it as a low-level, assembly-like language with a compact binary format. What makes it super cool is its ability to run with almost native performance. It's a fantastic compilation target for languages like C/C++, C#, and Rust, enabling them to work seamlessly on the web. Plus, it plays well with JavaScript, allowing them to team up for powerful web applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Why is WebAssembly Useful?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Imagine having the speed and efficiency of low-level languages directly in your web browser. WebAssembly makes this possible! It brings high-performance capabilities to web applications, allowing them to handle complex tasks smoothly and swiftly.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Use Cases of WebAssembly:&lt;/strong&gt;
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Performance-Intensive Tasks:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Ideal for tasks requiring heavy computation, like video editing or 3D graphics rendering.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Parallel Processing:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Well-suited for parallel processing, enhancing overall application speed.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&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%2Ffcpwew0ltxgemztuna7o.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%2Ffcpwew0ltxgemztuna7o.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;strong&gt;How Web Assembly Works&lt;/strong&gt;
&lt;/h1&gt;

&lt;p&gt;When you visit a website, your browser has two cool engines working behind the scenes – the JavaScript (JS) engine and the WebAssembly (Wasm) engine. Let's break down what happens with each.&lt;/p&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%2Fzulgm5zsvckumf9z4pdx.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%2Fzulgm5zsvckumf9z4pdx.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;JavaScript Engine Magic:&lt;/strong&gt;
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Parsing the Code:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;The JS engine starts by looking at the code you wrote on a website.&lt;/li&gt;
&lt;li&gt;It checks the code's grammar and structure to make sure it's correct.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Abstract Syntax Tree (AST):&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;If all is good, the engine creates an AST, which is like a tree structure representing your code.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Intermediate Representation (IR):&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;The AST becomes bytecode, a kind of middle-ground language that's easier for the computer to understand.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Machine Code Compilation:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Finally, the engine compiles this bytecode into machine code that your computer's processor can run.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Wasm Engine Magic:&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Now, let's see how WebAssembly brings its own magic to the party.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Writing Code with Types:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;With Wasm, you write your code using a statically-typed language, meaning you declare types in advance.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pre-compiled Wasm Module:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;You generate a pre-compiled Wasm module. Think of it like packaging your code in a neat box.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Skipping Parsing and IR:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Because Wasm code already has types, it skips the parsing and AST to IR steps that JS goes through.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Direct Compilation:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;The Wasm engine can then directly compile your neatly packaged code into machine code, saving time and making it super fast.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Why Wasm is Speedy:&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Type Declaration:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;JS checks variable types while running code (dynamic typing), but Wasm knows types in advance (static typing), making it faster.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Skip the Line:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Wasm skips some steps because it's pre-compiled and types are declared, giving it a shortcut to performance.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;In a nutshell, Wasm takes a faster route to get your code running in the browser, making web applications snappier and more efficient! 🚀&lt;/p&gt;

&lt;h1&gt;
  
  
  Let's Get Our Hands Dirty
&lt;/h1&gt;

&lt;p&gt;Alright, let's dive into the practical side of things! Make sure you have Node.js (latest version), Go Lang (version 1.21), and a basic understanding of both Go and React.js. If you're all set, here's a quick rundown of what we'll be doing:&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Set Up React Project with Vite
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Install Vite globally (if not already installed):&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; create-vite

&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Create a new React project:&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;create-vite my-react-wasm-app &lt;span class="nt"&gt;--template&lt;/span&gt; react

&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Navigate to the project:&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;my-react-wasm-app
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;go mod init my-react-wasm-app

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

&lt;/div&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;Step 2: Set Up Go Module&lt;/strong&gt;
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;After creating your React project, let's set up the Go module. Navigate to the project root and create a new folder named &lt;strong&gt;&lt;code&gt;go&lt;/code&gt;&lt;/strong&gt;.&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mkdir &lt;/span&gt;go
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Move into the &lt;strong&gt;&lt;code&gt;go&lt;/code&gt;&lt;/strong&gt; folder:&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;go
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Initialize a new Go module in this directory:&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;go mod init my-react-wasm-app/go
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now, your Go module is all set up within the &lt;strong&gt;&lt;code&gt;go&lt;/code&gt;&lt;/strong&gt; folder.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;Step 3: Write Go Code&lt;/strong&gt;
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Inside the &lt;strong&gt;&lt;code&gt;go&lt;/code&gt;&lt;/strong&gt; folder, create a new Go file, for example, &lt;strong&gt;&lt;code&gt;main.go&lt;/code&gt;&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Write a simple Go function in &lt;strong&gt;&lt;code&gt;main.go&lt;/code&gt;&lt;/strong&gt;. For instance, let's create a function that calculate Fibonacci sum:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kr"&gt;package&lt;/span&gt; &lt;span class="nx"&gt;main&lt;/span&gt;

&lt;span class="k"&gt;import &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;syscall/js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nx"&gt;func&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Create a channel to keep the Go program alive&lt;/span&gt;
    &lt;span class="nl"&gt;done&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;make&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;chan&lt;/span&gt; &lt;span class="nx"&gt;struct&lt;/span&gt;&lt;span class="p"&gt;{},&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c1"&gt;// Expose the Go function `fibonacciSum` to JavaScript&lt;/span&gt;
    &lt;span class="nx"&gt;js&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Global&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nc"&gt;Set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;wasmFibonacciSum&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;js&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;FuncOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fibonacciSum&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

    &lt;span class="c1"&gt;// Block the program from exiting&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;-&lt;/span&gt;&lt;span class="nx"&gt;done&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Define the Fibonacci sum function that will be exposed to JavaScript&lt;/span&gt;
&lt;span class="nx"&gt;func&lt;/span&gt; &lt;span class="nf"&gt;fibonacciSum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt; &lt;span class="nx"&gt;js&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="nx"&gt;p&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="nx"&gt;js&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="kr"&gt;interface&lt;/span&gt;&lt;span class="p"&gt;{}&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Retrieve the value of the argument passed from JavaScript&lt;/span&gt;
    &lt;span class="na"&gt;n&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nc"&gt;Int&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="c1"&gt;// Initialize variables for the Fibonacci sequence&lt;/span&gt;
    &lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;totalSum&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;

    &lt;span class="c1"&gt;// Calculate the Fibonacci sum up to the specified number&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="na"&gt;i&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;totalSum&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt;
        &lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="nx"&gt;b&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// Return the calculated Fibonacci sum as a JavaScript value&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;js&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;ValueOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;totalSum&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;h2&gt;
  
  
  Step 4: Convert Go Code to Wasm
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Build the Go code to generate WebAssembly:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This command will create a &lt;strong&gt;main.wasm&lt;/strong&gt; file containing the compiled WebAssembly code.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;GOARCH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;wasm &lt;span class="nv"&gt;GOOS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;js go build &lt;span class="nt"&gt;-o&lt;/span&gt; main.wasm

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

&lt;/div&gt;

&lt;ol&gt;
&lt;li&gt;Copy the &lt;code&gt;wasm_exec.js&lt;/code&gt; file to your project directory:&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cp&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;go &lt;span class="nb"&gt;env &lt;/span&gt;GOROOT&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;/misc/wasm/wasm_exec.js"&lt;/span&gt; &lt;span class="nb"&gt;.&lt;/span&gt;

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

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Explanation:&lt;/strong&gt;&lt;br&gt;
The &lt;code&gt;wasm_exec.js&lt;/code&gt; file is a support file provided by the Go standard library. It contains necessary functions to enable communication between Go and JavaScript in a WebAssembly environment. The &lt;code&gt;cp&lt;/code&gt; command copies this file from the Go installation directory (&lt;code&gt;$(go env GOROOT)/misc/wasm/&lt;/code&gt;) to your current project directory. Including this file in your project is essential for proper interaction between the Go code compiled to WebAssembly and the surrounding JavaScript environment.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 5: Use Wasm File in React.js
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;After generating the required wasm file (&lt;code&gt;main.wasm&lt;/code&gt;), move the file to the public folder of your React.js application. This folder is typically located at the root level of your project.&lt;/li&gt;
&lt;li&gt;Move the &lt;code&gt;wasm_exec.js&lt;/code&gt; file to the &lt;code&gt;src&lt;/code&gt; folder of your React.js application. This folder is where your source code resides.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;In your React component (&lt;strong&gt;&lt;code&gt;App.tsx&lt;/code&gt;&lt;/strong&gt;), import the necessary dependencies:&lt;/p&gt;
&lt;pre class="highlight tsx"&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;useEffect&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./wasm_exec.js&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="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./wasmTypes.d.ts&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;/li&gt;
&lt;li&gt;
&lt;p&gt;Define a WebAssembly function wrapper:&lt;/p&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;wasmFibonacciSum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kr"&gt;number&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;resolve&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;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;wasmFibonacciSum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;n&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;res&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;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Step 5: Finalize &lt;code&gt;App.tsx&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Here is the final version of &lt;code&gt;App.tsx&lt;/code&gt;:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&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;useEffect&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./wasm_exec.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// Import the wasm_exec.js file for Go-Wasm compatibility&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./wasmTypes.d.ts&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// Import the TypeScript declarations for WebAssembly&lt;/span&gt;

&lt;span class="c1"&gt;// Function to wrap the wasmFibonacciSum function for asynchronous handling&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;wasmFibonacciSum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kr"&gt;number&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;resolve&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="c1"&gt;// Call the wasmFibonacciSum function from Go&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;wasmFibonacciSum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;n&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;res&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="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="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="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;isWasmLoaded&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setIsWasmLoaded&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;);&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;wasmResult&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setWasmResult&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kr"&gt;number&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="c1"&gt;// useEffect hook to load WebAssembly when the component mounts&lt;/span&gt;
  &lt;span class="nf"&gt;useEffect&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="c1"&gt;// Function to asynchronously load WebAssembly&lt;/span&gt;
    &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;loadWasm&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;void&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="c1"&gt;// Create a new Go object&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;goWasm&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Go&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;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;WebAssembly&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;instantiateStreaming&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="c1"&gt;// Fetch and instantiate the main.wasm file&lt;/span&gt;
        &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;main.wasm&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;  
        &lt;span class="c1"&gt;// Provide the import object to Go for communication with JavaScript&lt;/span&gt;
        &lt;span class="nx"&gt;goWasm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;importObject&lt;/span&gt;  
      &lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="c1"&gt;// Run the Go program with the WebAssembly instance&lt;/span&gt;
      &lt;span class="nx"&gt;goWasm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;instance&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
      &lt;span class="nf"&gt;setIsWasmLoaded&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="p"&gt;}&lt;/span&gt;

    &lt;span class="nf"&gt;loadWasm&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="c1"&gt;// Function to handle button click and initiate WebAssembly calculation&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;handleClickButton&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;async &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;n&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// Choose a value for n&lt;/span&gt;

    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Starting WebAssembly calculation...&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;wasmStartTime&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;performance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

    &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="c1"&gt;// Call the wasmFibonacciSum function asynchronously&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;wasmFibonacciSum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
      &lt;span class="nf"&gt;setWasmResult&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 
      &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;WebAssembly Result:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;WebAssembly Error:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;wasmEndTime&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;performance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`WebAssembly Calculation Time: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;wasmEndTime&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;wasmStartTime&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; ms`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;

  &lt;span class="c1"&gt;// JSX markup for the React component&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&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;isWasmLoaded&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&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;Wasm Loaded&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="si"&gt;}&lt;/span&gt; 
      &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;isWasmLoaded&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&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;Wasm not Loaded&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="si"&gt;}&lt;/span&gt; 

      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt; &lt;span class="na"&gt;onClick&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;handleClickButton&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Handle Click Wasm&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;button&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;wasmResult&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&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="p"&gt;&amp;gt;&lt;/span&gt;WebAssembly Result: &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;wasmResult&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="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;)&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;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&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="nx"&gt;App&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;Explanation:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The final &lt;code&gt;App.tsx&lt;/code&gt; integrates WebAssembly seamlessly into a React application.&lt;/li&gt;
&lt;li&gt;It loads the WebAssembly module when the component mounts, displays a message indicating if WebAssembly is loaded or not, and triggers a WebAssembly calculation when the button is clicked.&lt;/li&gt;
&lt;li&gt;The result of the calculation is displayed below the button.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Feel free to customize the values and calculations according to your specific use case. Your React application is now fully equipped to leverage the power of WebAssembly! 🚀&lt;/p&gt;

&lt;p&gt;Please check the complete code repository at: &lt;a href="https://github.com/akshays-repo/wasm-react" rel="noopener noreferrer"&gt;https://github.com/akshays-repo/wasm-react&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;strong&gt;Some Useful Blogs and Resources&lt;/strong&gt;
&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Learn techniques to optimize the size of Go WebAssembly binaries for improved web application performance : &lt;a href="https://dev.bitolog.com/minimizing-go-webassembly-binary-size/" rel="noopener noreferrer"&gt;https://dev.bitolog.com/minimizing-go-webassembly-binary-size/&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Explore how Figma utilized WebAssembly to reduce load times significantly, providing insights into real-world performance improvements:  &lt;a href="https://www.figma.com/blog/webassembly-cut-figmas-load-time-by-3x/" rel="noopener noreferrer"&gt;https://www.figma.com/blog/webassembly-cut-figmas-load-time-by-3x/&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>react</category>
      <category>go</category>
      <category>webassembly</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Building a Confirmation Dialog Component with React and Material-UI</title>
      <dc:creator>Akshay S</dc:creator>
      <pubDate>Wed, 31 May 2023 12:19:55 +0000</pubDate>
      <link>https://dev.to/akshaysrepo/building-a-confirmation-dialog-component-with-react-and-material-ui-4468</link>
      <guid>https://dev.to/akshaysrepo/building-a-confirmation-dialog-component-with-react-and-material-ui-4468</guid>
      <description>&lt;h2&gt;
  
  
  Introduction:
&lt;/h2&gt;

&lt;p&gt;Confirmation Dialogs are a crucial UI component in many applications. They prompt users to confirm or cancel actions that have significant consequences. In this blog post, we will explore how to create a reusable Confirmation Dialog component using React and Material-UI. We will dive into the code and explain its functionality, as well as demonstrate how to use the component in your React applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  Code
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { useState } from "react";
import {
  Dialog,
  Button,
  DialogTitle,
  DialogContent,
  DialogContentText,
  DialogActions,
} from "@material-ui/core";

function ConfirmationDialog(props) {
  //local states
  const [open, setOpen] = useState(false);

  const showDialog = () =&amp;gt; {
    setOpen(true);
  };

  const hideDialog = () =&amp;gt; {
    setOpen(false);
  };

  const confirmRequest = () =&amp;gt; {
    props.response();
    hideDialog();
  };

  return (
    &amp;lt;&amp;gt;
      {props.children(showDialog)}
      {open &amp;amp;&amp;amp; (
        &amp;lt;Dialog
          open={open}
          onClose={hideDialog}
          aria-labelledby="alert-dialog-title"
          aria-describedby="alert-dialog-description"
        &amp;gt;
          &amp;lt;DialogTitle id="alert-dialog-title"&amp;gt;{props.title}&amp;lt;/DialogTitle&amp;gt;
          &amp;lt;DialogContent&amp;gt;
            &amp;lt;DialogContentText id="alert-dialog-description"&amp;gt;
              {props.description}
            &amp;lt;/DialogContentText&amp;gt;
          &amp;lt;/DialogContent&amp;gt;
          &amp;lt;DialogActions&amp;gt;
            &amp;lt;Button onClick={confirmRequest} color="primary"&amp;gt;
              Yes
            &amp;lt;/Button&amp;gt;
            &amp;lt;Button onClick={hideDialog} color="primary"&amp;gt;
              No
            &amp;lt;/Button&amp;gt;
          &amp;lt;/DialogActions&amp;gt;
        &amp;lt;/Dialog&amp;gt;
      )}
    &amp;lt;/&amp;gt;
  );
}

export default ConfirmationDialog;

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  Example usage:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import ConfirmationDialog from './ConfirmationDialog';

function MyComponent() {
  const handleConfirmation = () =&amp;gt; {
    // Perform action upon confirmation
    console.log('Confirmed!');
  };

  return (
    &amp;lt;ConfirmationDialog
      title="Confirmation"
      description="Are you sure you want to proceed?"
      response={handleConfirmation}
    &amp;gt;
      {(showDialog) =&amp;gt; (
        &amp;lt;button onClick={showDialog}&amp;gt;Open Confirmation Dialog&amp;lt;/button&amp;gt;
      )}
    &amp;lt;/ConfirmationDialog&amp;gt;
  );
}

export default MyComponent;

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

&lt;/div&gt;



&lt;p&gt;In the above example, we import the ConfirmationDialog component and use it within the MyComponent component. When the user clicks the "Open Confirmation Dialog" button, the Confirmation Dialog will appear with the provided title and description. Upon confirming, the handleConfirmation function will be executed.&lt;/p&gt;

</description>
      <category>react</category>
      <category>dialog</category>
      <category>materal</category>
      <category>javascript</category>
    </item>
    <item>
      <title>useMemo vs usecallback in simple terms</title>
      <dc:creator>Akshay S</dc:creator>
      <pubDate>Mon, 16 Jan 2023 15:51:37 +0000</pubDate>
      <link>https://dev.to/akshaysrepo/usememo-vs-usecallback-in-simple-terms-5af8</link>
      <guid>https://dev.to/akshaysrepo/usememo-vs-usecallback-in-simple-terms-5af8</guid>
      <description>&lt;p&gt;When building a React application, two hooks that are commonly used for performance optimization are useMemo and useCallback.&lt;/p&gt;

&lt;p&gt;useMemo is a hook that allows you to cache the result of a expensive computation and only re-evaluate it when one of the dependencies has changed. This can greatly improve the performance of your application by avoiding unnecessary re-renders.&lt;/p&gt;

&lt;p&gt;useCallback is similar to useMemo, but it is used to cache the reference to a function, instead of caching the result of a computation. This is useful when passing a function down as a prop to a child component and you want to avoid re-creating the function on every render.&lt;/p&gt;

&lt;p&gt;In short, useMemo is used to cache the result of a computation and useCallback is used to cache the reference to a function. Both can help improve the performance of your React application by avoiding unnecessary re-renders.&lt;br&gt;
&lt;/p&gt;

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

function MyComponent({ data }) {
  const memoizedData = useMemo(() =&amp;gt; {
    // perform expensive computation on data
    return data.map(item =&amp;gt; item * 2);
  }, [data]);

  const handleClick = useCallback(() =&amp;gt; {
    console.log(memoizedData);
  }, [memoizedData]);

  return (
    &amp;lt;div&amp;gt;
      &amp;lt;button onClick={handleClick}&amp;gt;Log Data&amp;lt;/button&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}

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

&lt;/div&gt;



&lt;p&gt;In this example, useMemo is used to memoize the result of an expensive computation performed on the data prop. This means that the computation will only be performed again if the data prop changes.&lt;/p&gt;

&lt;p&gt;useCallback is then used to create a callback function that will only change if the memoizedData value changes. This is useful when passing the callback as a prop to a child component, as it will help prevent unnecessary re-renders of the child component.&lt;/p&gt;

</description>
      <category>gratitude</category>
    </item>
    <item>
      <title>An Better way to call mui alert dialog</title>
      <dc:creator>Akshay S</dc:creator>
      <pubDate>Sun, 17 Jul 2022 14:56:09 +0000</pubDate>
      <link>https://dev.to/akshaysrepo/an-better-way-to-call-mui-alert-dialog-18n7</link>
      <guid>https://dev.to/akshaysrepo/an-better-way-to-call-mui-alert-dialog-18n7</guid>
      <description>&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;p&gt;Install mui-react-alert with npm&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  npm i mui-react-alert
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://codesandbox.io/s/funny-mestorf-k2dcph"&gt;https://codesandbox.io/s/funny-mestorf-k2dcph&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Usage/Examples
&lt;/h2&gt;

&lt;p&gt;App.tsx&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;AlertDialog&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;mui-react-alert&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="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="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;App&lt;/span&gt;&lt;span class="dl"&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;AlertDialog&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;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;Button.tsx&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;showAlertConfirmarion&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;mui-react-alert&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;Button&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt;
      &lt;span class="nx"&gt;onClick&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="nx"&gt;showAlertConfirmarion&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
          &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Use Google's location service?&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="na"&gt;cancelLabel&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;DISAGREE&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="na"&gt;confirmLabel&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;AGREE&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="na"&gt;subtitle&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Let Google help apps determine location. This means sending anonymous location data to Google, even when no apps are running.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="na"&gt;onConfirmation&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nx"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Say hello&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;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="nx"&gt;Show&lt;/span&gt; &lt;span class="nx"&gt;alert&lt;/span&gt; &lt;span class="nx"&gt;dialog&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/button&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;Button&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

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

&lt;/div&gt;



</description>
      <category>javascript</category>
      <category>react</category>
      <category>typescript</category>
      <category>materialui</category>
    </item>
  </channel>
</rss>
