<?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: Ashish maurya</title>
    <description>The latest articles on Forem by Ashish maurya (@theashishmaurya).</description>
    <link>https://forem.com/theashishmaurya</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%2F382771%2F8d628c60-5259-4551-9309-6b554e609ce2.jpeg</url>
      <title>Forem: Ashish maurya</title>
      <link>https://forem.com/theashishmaurya</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/theashishmaurya"/>
    <language>en</language>
    <item>
      <title>We've Implemented Enterprise Integrations for Years. Here's the Honest iPaaS Landscape in 2026.</title>
      <dc:creator>Ashish maurya</dc:creator>
      <pubDate>Wed, 15 Apr 2026 05:03:28 +0000</pubDate>
      <link>https://forem.com/theashishmaurya/weve-implemented-enterprise-integrations-for-years-heres-the-honest-ipaas-landscape-in-2026-ib5</link>
      <guid>https://forem.com/theashishmaurya/weve-implemented-enterprise-integrations-for-years-heres-the-honest-ipaas-landscape-in-2026-ib5</guid>
      <description>&lt;h2&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%2Fnrndepxs8mbmb1qcrcn6.png" alt="Enterprise integration platform comparison 2026 — evaluating iPaaS for governance, automation, and no-code workflows" width="800" height="447"&gt;
&lt;/h2&gt;

&lt;p&gt;At Ivoyant, enterprise integration is what we do. We've designed, built, and supported integration architectures across healthcare, financial services, manufacturing, and retail — running on MuleSoft, Boomi, Workato, n8n, and everything in between. Over the years we've been brought in to clean up platform migrations that went wrong, extend integrations that the original vendor couldn't support, and help IT leaders figure out why their $300K iPaaS wasn't delivering what the sales team promised.&lt;/p&gt;

&lt;p&gt;Eventually, that pattern of problems pushed us to build &lt;a href="https://koodisi.com" rel="noopener noreferrer"&gt;Koodisi&lt;/a&gt; — our own enterprise iPaaS, designed around what we kept wishing these platforms would just do by default.&lt;/p&gt;

&lt;p&gt;I want to be upfront about that. I work at Ivoyant. We make Koodisi. This post isn't from a neutral third party. But it is from practitioners who have lived inside these other platforms — as implementers, as architects, and sometimes as the team called in when things go sideways. The analysis below is honest. If MuleSoft is the right answer for your situation, I'll tell you that.&lt;/p&gt;




&lt;h2&gt;
  
  
  What Enterprise Teams Actually Need
&lt;/h2&gt;

&lt;p&gt;Before the platforms: the requirements.&lt;/p&gt;

&lt;p&gt;Across the engagements we've worked on, the needs are rarely exotic. Most teams need an integration platform that can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Run multi-step workflows across Salesforce, Workday, NetSuite, ServiceNow, and a mix of internal REST APIs&lt;/li&gt;
&lt;li&gt;Be operated by both integration engineers &lt;strong&gt;and&lt;/strong&gt; the operations team (who are not developers)&lt;/li&gt;
&lt;li&gt;Support a real deployment pipeline — dev, staging, production, with approvals&lt;/li&gt;
&lt;li&gt;Produce audit logs that can go to compliance without embarrassment&lt;/li&gt;
&lt;li&gt;Not require a dedicated DevOps team just to keep the platform itself running&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That last point is where the majority of platforms start breaking down. And it's the one that's almost never covered in feature comparison tables.&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%2Foh0u6kh09r1c9bxhi3zy.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%2Foh0u6kh09r1c9bxhi3zy.png" alt="Enterprise iPaaS evaluation matrix — governance vs ease of use for integration platforms" width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  The Platforms in Practice
&lt;/h2&gt;

&lt;p&gt;Here's the landscape as we've seen it — not from a 30-day trial, but from implementation work.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;MuleSoft (Anypoint Platform)&lt;/strong&gt; — The gold standard for complex enterprise integration, but the licensing and implementation complexity will humble you fast. Mid-market teams routinely spend $400K+ in year one and still aren't in production at the end of it. We've seen it. Where MuleSoft makes sense, it's the right tool. Where it doesn't, the sunk cost becomes a serious organizational problem.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Boomi (Dell Technologies)&lt;/strong&gt; — Mature, stable, and widely adopted. Boomi has deep connector coverage that reflects 20+ years of integrations built up. The UX is showing its age, and the pricing model has become harder to predict as workloads grow. Still a solid mid-tier choice for the right stack.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Workato&lt;/strong&gt; — Recipe-based automation done well. Strong for operations-oriented teams and accessible without deep technical training. The per-recipe pricing compounds fast at scale, and the governance model feels layered on rather than designed in — which becomes a real issue in regulated environments.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;n8n&lt;/strong&gt; — Excellent developer tool with a genuinely impressive integrations catalog. The Community Edition is free to self-host, but "free to license" is not the same as "free to run." Someone has to operate it, secure it, patch it, and back it up. For enterprises without a DevOps team dedicated to the iPaaS layer, the self-hosted model creates a hidden operational burden that tends to surface at the worst possible moment.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Zapier&lt;/strong&gt; — Good consumer and SMB automation tool, not an enterprise iPaaS. The per-task pricing at enterprise volumes becomes uncomfortable quickly, and there's no meaningful governance story. Worth understanding because business units frequently adopt it independently, which creates its own migration complexity later.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Celigo&lt;/strong&gt; — Focused heavily on NetSuite and eCommerce workflows. Solid in those lanes. Less compelling for teams outside that vertical.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Koodisi&lt;/strong&gt; — What we built, so I'll treat this separately below. The short version: it's designed around the governance and operational visibility gaps we kept running into everywhere else.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Problem Nobody Writes About: Governance and Change Control
&lt;/h2&gt;

&lt;p&gt;Here's what integration platform reviews almost universally skip: &lt;strong&gt;what happens after you build the workflow?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Most comparisons stop at the builder UX. That's the wrong place to stop. The question that actually matters is: &lt;em&gt;what happens when a workflow breaks in production at 2am and the engineer on call has never touched this part of the platform?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Enterprise governance in practice means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Every workflow change goes through a structured review before it reaches production&lt;/li&gt;
&lt;li&gt;Every deployment is versioned, logged, and reversible&lt;/li&gt;
&lt;li&gt;Failures surface with execution context — not just "workflow failed," but &lt;em&gt;which step&lt;/em&gt;, &lt;em&gt;which record&lt;/em&gt;, &lt;em&gt;what the error actually was&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;Roles determine who can build, who can approve, who can deploy — scoped to the workspace, not just set globally per account&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Most platforms treat this as an add-on. It shows in the implementation. And it shows even more in the post-go-live support.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;MuleSoft&lt;/strong&gt; has the governance story — but it requires certified MuleSoft architects to use it properly. The capability is real. The accessibility is not.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Workato&lt;/strong&gt; has approval workflows and audit logs. They're functional. They're not deep enough for teams with real compliance requirements.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;n8n&lt;/strong&gt; (self-hosted) has essentially none of this out of the box. SSO, Git sync, and environment support moved to the Business plan ($800+/month). The Community Edition is free to host, but you're writing your own governance story around it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Koodisi&lt;/strong&gt; — this is the gap we designed against. Governance isn't a settings tab in Koodisi; it's the deployment model. Every workflow lives in a workspace with RBAC. Every deployment moves through a pipeline: Dev → Deploy → Test → Promote. Rollbacks are built in. Execution traces are written for the operations team, not just the engineer who built the workflow.&lt;/p&gt;

&lt;p&gt;More on this: &lt;a href="https://koodisi.com/compare/koodisi-vs-n8n" rel="noopener noreferrer"&gt;Koodisi vs n8n — enterprise governance comparison&lt;/a&gt;.&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%2F3yvluxn0ogfdyhmlukoa.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%2F3yvluxn0ogfdyhmlukoa.png" alt="No-code enterprise iPaaS with structured deployment pipeline — dev, staging, production approval workflow" width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  The Cost Reality
&lt;/h2&gt;

&lt;p&gt;Numbers are more useful than adjectives like "expensive" or "affordable."&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;MuleSoft&lt;/strong&gt; enterprise contracts start around $150K/year and routinely exceed $500K for mid-to-large deployments once Anypoint Platform licensing, runtime licenses, and professional services are loaded in. G2 reviews and community discussions put most enterprise MuleSoft deployments at $250K–$600K annually, fully burdened.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Boomi&lt;/strong&gt; is less steep but still substantial. Community Edition works for light use. Production-grade deployments with Flow, API Management, and Master Data Hub add up — expect $50K–$200K depending on usage.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Workato&lt;/strong&gt; quotes per recipe, which makes forecasting difficult. Teams with 50+ active recipes frequently report $30K–$80K/year, and that tends to scale as automation success creates more automation demand.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;n8n&lt;/strong&gt; Cloud starts at $20/month (billed annually) and goes to $800/month for the Business tier. Self-hosted Community Edition carries no licensing cost, but factor in infrastructure management, upgrades, security patching, and backup operations — that "free" cost becomes real.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Koodisi&lt;/strong&gt; enterprise pricing isn't published publicly. See the &lt;a href="https://koodisi.com/pricing" rel="noopener noreferrer"&gt;pricing page&lt;/a&gt; for positioning, or reach out directly. The model is designed to be accessible to mid-market teams who've outgrown SaaS automation tools but can't absorb MuleSoft-tier spend.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Operational Blind Spot
&lt;/h2&gt;

&lt;p&gt;One pattern we've seen repeatedly across client environments: &lt;strong&gt;the operations team can't use the platform the integration team built on.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Operations teams need to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;See which workflows ran today and which failed&lt;/li&gt;
&lt;li&gt;Understand what a failure means without parsing a stack trace&lt;/li&gt;
&lt;li&gt;Retry a failed workflow without filing an IT ticket&lt;/li&gt;
&lt;li&gt;Know when a scheduled workflow simply hasn't run&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;On MuleSoft, Boomi, and n8n — this is a developer-only activity. Logs exist. They are not readable by someone unfamiliar with the platform internals. The result is that operations teams become dependent on engineering for visibility into processes they nominally own.&lt;/p&gt;

&lt;p&gt;This is what Gartner refers to as the "citizen integration" gap — and it's a real operational problem, not just a UX complaint. The gap between technical and operational users needs to close at the platform level, not through training programs.&lt;/p&gt;

&lt;p&gt;In Koodisi, execution traces are written to be readable without coaching. That was a deliberate design decision, informed by watching operations teams struggle with every other platform we've worked on.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where the Traditional Players Are Still the Right Answer
&lt;/h2&gt;

&lt;p&gt;I want to be direct here, because "everything is broken except the tool I'm associated with" is not a credible take.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;MuleSoft&lt;/strong&gt; is genuinely the right choice if you have a large, heterogeneous enterprise with hundreds of integrations, a dedicated integration team with MuleSoft certifications, and the budget and timeline to match. Nobody competes with its depth of enterprise connectors or its API management story at scale. If you're in that situation, use it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Boomi&lt;/strong&gt; carries 20+ years of integration expertise in its connector library. For SAP-heavy environments, Boomi's SAP integration support is notably strong. It's well-established in manufacturing and logistics verticals where that depth matters. For the right stack, it's a solid, low-drama choice.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;n8n&lt;/strong&gt; is an excellent tool for developer-led teams comfortable operating infrastructure. If you have a strong DevOps culture and no significant compliance burden, the self-hosted Community Edition is genuinely powerful. We'd recommend it for a developer-heavy SMB or a startup — and not recommend it where governance and managed operations are requirements.&lt;/p&gt;




&lt;h2&gt;
  
  
  What We've Seen Work for Mid-Market Teams
&lt;/h2&gt;

&lt;p&gt;The pattern we see most often among teams that successfully modernize their integration layer:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;MuleSoft is ruled out on cost or implementation timeline&lt;/li&gt;
&lt;li&gt;Boomi gets close, but the UX creates real operations team adoption risk&lt;/li&gt;
&lt;li&gt;n8n is off the table because there's no DevOps headcount to run it&lt;/li&gt;
&lt;li&gt;The remaining options are Workato and Koodisi&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Workato tends to win on connector breadth at the SMB end. Koodisi tends to win where governance, operations team usability, and API management are all requirements — particularly for teams that expose internal APIs to external partners and need structured change control across both sides.&lt;/p&gt;

&lt;p&gt;The clients we've seen get the most out of Koodisi are running 30–80 integrations in production, operating across IT and business operations teams, and dealing with compliance requirements that make the audit trail matter.&lt;/p&gt;

&lt;p&gt;If that profile fits your situation, &lt;a href="https://koodisi.com/request-demo" rel="noopener noreferrer"&gt;request a demo&lt;/a&gt; and test it against your specific workflows — not against a generic benchmark.&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%2Fa0z1uy9qd6b0pnt4t7b0.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%2Fa0z1uy9qd6b0pnt4t7b0.png" alt="Enterprise iPaaS production dashboard — integration metrics, uptime, and compliance status" width="800" height="432"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Frequently Asked Questions
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What's the difference between iPaaS and workflow automation tools like Zapier?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;iPaaS (Integration Platform as a Service) is designed for enterprise-grade integration — multi-step workflows, bidirectional data sync, API management, governance, and operational visibility. Zapier is built for simple trigger-action automations at the individual or SMB level. At enterprise scale, iPaaS provides the audit trails, access controls, and deployment pipelines that automation tools don't offer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Is MuleSoft still worth the cost in 2026?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For large enterprises with dedicated integration teams and complex, multi-domain needs — yes. For mid-market teams that can't justify a $300K+ annual platform spend plus specialist staffing, the value calculation has shifted significantly. See &lt;a href="https://koodisi.com/compare/koodisi-vs-mulesoft" rel="noopener noreferrer"&gt;Koodisi vs MuleSoft&lt;/a&gt; for a direct comparison.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What should I actually look for in an enterprise iPaaS?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Beyond connector count: Is governance designed in or bolted on? Does the deployment pipeline support dev/staging/production with approvals? Can non-developers actually operate it day to day? What's the total cost of ownership, including DevOps overhead? Most platform comparisons skip the last two — they're usually where the surprises are.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How long does it take to properly evaluate an enterprise integration platform?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Budget 6–8 weeks for a real proof of concept. Set up your actual use cases (not demo scenarios), include your operations team in testing — not just engineers — and pay close attention to what happens when something fails. How a platform behaves in failure tells you more than how it behaves on the happy path.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Is n8n a real enterprise iPaaS?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;n8n is a strong developer-led automation platform. It's not a traditional enterprise iPaaS. The self-hosted Community Edition is powerful but requires real DevOps investment. Cloud plans scale to $800/month for Business tiers. For enterprises that need managed infrastructure, RBAC, and a structured deployment lifecycle, a purpose-built iPaaS is a better fit. &lt;a href="https://koodisi.com/compare/koodisi-vs-n8n" rel="noopener noreferrer"&gt;Full comparison here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What's a good Boomi alternative for mid-market teams?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Workato and Koodisi are the most direct alternatives. Koodisi specifically addresses the governance and API management gaps that come up most often in Boomi migration conversations. See the &lt;a href="https://koodisi.com/compare" rel="noopener noreferrer"&gt;full comparison&lt;/a&gt;.&lt;/p&gt;




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

&lt;p&gt;Enterprise integration is genuinely hard. The platforms are rarely the hard part — the governance model, the operational handoff from engineers to ops teams, and the change control story are the hard parts. Pick a platform that takes those seriously from the start, not one where you'll be retrofitting them in year two.&lt;/p&gt;

&lt;p&gt;The mid-market options in 2026 are meaningfully better than they were even two years ago. You no longer have to choose between "MuleSoft budget" and "run your own infrastructure." There are real, production-grade options in between.&lt;/p&gt;

&lt;p&gt;Whatever you evaluate: ask every vendor what happens when a workflow breaks at 2am and your senior integration engineer is unreachable. The specificity of the answer tells you everything about how seriously they've thought about operations.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;I work at Ivoyant, the team behind Koodisi. Everything in this post reflects what we've seen across real client engagements — but you should factor in that perspective. I'm happy to answer questions in the comments.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>lowcode</category>
      <category>ai</category>
      <category>ipaas</category>
      <category>software</category>
    </item>
    <item>
      <title>Multithreading In JavaScript using Web Workers</title>
      <dc:creator>Ashish maurya</dc:creator>
      <pubDate>Mon, 15 Aug 2022 10:38:40 +0000</pubDate>
      <link>https://forem.com/theashishmaurya/multithreading-in-javascript-using-web-workers-1fh3</link>
      <guid>https://forem.com/theashishmaurya/multithreading-in-javascript-using-web-workers-1fh3</guid>
      <description>&lt;p&gt;Have you ever heard that Javascript is a single-threaded language and can only execute one process at a time well that is completely true. JavaScript uses an event loop to execute the process, for now, think of the event loop is as a queue where all the Javascript processes kept inside and are executed one by one.&lt;/p&gt;

&lt;p&gt;In older Browsers, the whole browser was executed on Only one thread but now Each tab of the browser is given a thread to execute the process on.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HL_UhKlZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1660493194715/tf0OFi3hT.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HL_UhKlZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1660493194715/tf0OFi3hT.png" alt=" Javascript EventLoop" width="739" height="471"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1 id="heading-problem-with-single-threaded-programing-language"&gt;Problem with Single threaded Programing Language.&lt;/h1&gt;

&lt;p&gt;As JavaScript is a single-threaded Programing language so now only one Process can be executed in one tab. You will have a better understanding of this if you are familiar with Event Loop in Javascript.&lt;/p&gt;

&lt;p&gt;For normal purposes, It is more than enough but for the CPU-intensive process, this can cause major issues in the UI. Suppose you want to do a certain CPU-intensive task and while doing it another process will stop working such as clicking or scrolling or anything else you do on the website.&lt;/p&gt;

&lt;p&gt;Here is an example where I calculate a sum of all the numbers in the range using a for loop. &lt;/p&gt;


&lt;pre&gt;&lt;code&gt;let sum &lt;span class="hljs-operator"&gt;=&lt;/span&gt; &lt;span class="hljs-number"&gt;0&lt;/span&gt;;&lt;br&gt;
  &lt;span class="hljs-keyword"&gt;for&lt;/span&gt; (let i &lt;span class="hljs-operator"&gt;=&lt;/span&gt; &lt;span class="hljs-number"&gt;0&lt;/span&gt;; i &lt;span class="hljs-operator"&gt;&amp;lt;&lt;/span&gt; &lt;span class="hljs-number"&gt;10000000000&lt;/span&gt;; i&lt;span class="hljs-operator"&gt;+&lt;/span&gt;&lt;span class="hljs-operator"&gt;+&lt;/span&gt;) {&lt;br&gt;
    sum &lt;span class="hljs-operator"&gt;+&lt;/span&gt;&lt;span class="hljs-operator"&gt;=&lt;/span&gt; i;&lt;br&gt;
  }&lt;br&gt;
  alert(&lt;span class="hljs-string"&gt;"The sum is: "&lt;/span&gt; &lt;span class="hljs-operator"&gt;+&lt;/span&gt; sum);&lt;br&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let's see what happens in the browser if I run this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--onOk0HC3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1660492675114/TkQBEpHXX.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--onOk0HC3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1660492675114/TkQBEpHXX.gif" alt="webWorker.gif" width="646" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;let's understand what happening here In this Gif. Here are two Buttons one is to change the background color of the Website and one is to do CPU-intensive work which is to calculate the Sum and once done it just shows the sum on the screen as the gif.&lt;/p&gt;

&lt;p&gt;Now before I clicked on the Calculate sum button I was able to change the background of the Website but once I click on the Calculate Sum the javascript will only execute any other process once it calculate the other. As executing the calculated Sum takes a lot of time it just freezes all the other processes.&lt;/p&gt;

&lt;p&gt;Well, this can be solved by using something called web workers.&lt;/p&gt;

&lt;h1 id="heading-modern-problem-required-morden-solution"&gt;Modern Problem Required Morden Solution&lt;/h1&gt;

&lt;h2 id="heading-an-introduction-to-web-workers"&gt;An Introduction to Web Workers&lt;/h2&gt;

&lt;p&gt;MDN in their official document says and I quote&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Web Workers are a simple means for web content to run scripts in background threads.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Meaning you can now run your Javascript Script on a different thread in the background. Which is exactly the solution we are looking for.&lt;/p&gt;

&lt;p&gt;Let's try to do that using a web worker, as a web worker needs a new script so will create a new script for that let's call that a &lt;code&gt;worker.js&lt;/code&gt;, and in our &lt;code&gt;main.js&lt;/code&gt; let's initiate the worker script using the single line &lt;code&gt;new Worker("worker.js")&lt;/code&gt;this is how easily a new worker can be initiated in your already written javascript.&lt;/p&gt;

&lt;p&gt;Our main.js will look something like this &lt;/p&gt;


&lt;pre&gt;&lt;code&gt;&lt;span class="hljs-comment"&gt;// main.js &lt;/span&gt;

&lt;p&gt;const calculateSum &lt;span&gt;=&lt;/span&gt; document.getElementById(&lt;span&gt;"calculateSum"&lt;/span&gt;);&lt;br&gt;
const changeColor &lt;span&gt;=&lt;/span&gt; document.getElementById(&lt;span&gt;"changeColor"&lt;/span&gt;);&lt;/p&gt;

&lt;p&gt;const worker &lt;span&gt;=&lt;/span&gt; &lt;span&gt;new&lt;/span&gt; Worker(&lt;span&gt;"worker.js"&lt;/span&gt;);&lt;br&gt;
calculateSum.addEventListener(&lt;span&gt;"click"&lt;/span&gt;, &lt;span&gt;&lt;span&gt;function&lt;/span&gt; (&lt;span&gt;&lt;/span&gt;) &lt;/span&gt;{&lt;/p&gt;

&lt;p&gt;&lt;span&gt;// We posted a message to the worker with a simple JSON as we don't require to pass any data&lt;/span&gt;&lt;br&gt;
  worker.postMessage({ text: &lt;span&gt;"sum"&lt;/span&gt; });&lt;/p&gt;

&lt;p&gt;&lt;span&gt;// Our worker is listening to the return message then it will execute some logic on the basis of data passed.&lt;/span&gt;&lt;br&gt;
  worker.onmessage &lt;span&gt;=&lt;/span&gt; &lt;span&gt;&lt;span&gt;function&lt;/span&gt; (&lt;span&gt;e&lt;/span&gt;) &lt;/span&gt;{&lt;br&gt;
    document.getElementById(&lt;span&gt;"sum"&lt;/span&gt;).innerHTML &lt;span&gt;=&lt;/span&gt; &lt;code&gt;the sume &amp;lt;span class="hljs-keyword"&amp;gt;is&amp;lt;/span&amp;gt; ${e.data}&lt;/code&gt;;&lt;br&gt;
    worker.terminate() &lt;span&gt;//terminatiing the worker after the use&lt;/span&gt;&lt;br&gt;
  };&lt;br&gt;
});&lt;/p&gt;

&lt;p&gt;changeColor.addEventListener(&lt;span&gt;"click"&lt;/span&gt;, &lt;span&gt;&lt;span&gt;function&lt;/span&gt; (&lt;span&gt;&lt;/span&gt;) &lt;/span&gt;{&lt;br&gt;
  document.body.style.backgroundColor &lt;span&gt;=&lt;/span&gt;&lt;br&gt;
    document.body.style.backgroundColor &lt;span&gt;=&lt;/span&gt;&lt;span&gt;=&lt;/span&gt; &lt;span&gt;"red"&lt;/span&gt; ? &lt;span&gt;"blue"&lt;/span&gt; : &lt;span&gt;"red"&lt;/span&gt;;&lt;br&gt;
});&lt;br&gt;
&lt;/p&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;now as you can see I have moved the logic to calculate the sum from the main.js to the worker.js&lt;/p&gt;
&lt;br&gt;
&lt;pre&gt;&lt;code&gt;&lt;span class="hljs-comment"&gt;// worker.js&lt;/span&gt;

&lt;p&gt;onmessage &lt;span&gt;=&lt;/span&gt; (e) &lt;span&gt;=&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt; {&lt;br&gt;
  let sum &lt;span&gt;=&lt;/span&gt; &lt;span&gt;0&lt;/span&gt;;&lt;br&gt;
  &lt;span&gt;for&lt;/span&gt; (let i &lt;span&gt;=&lt;/span&gt; &lt;span&gt;0&lt;/span&gt;; i &lt;span&gt;&amp;lt;&lt;/span&gt; &lt;span&gt;10000&lt;/span&gt;; i&lt;span&gt;+&lt;/span&gt;&lt;span&gt;+&lt;/span&gt;) {&lt;br&gt;
    arr[i] &lt;span&gt;=&lt;/span&gt; i;&lt;br&gt;
  }&lt;br&gt;
  postMessage(sum);&lt;br&gt;
};&lt;br&gt;
&lt;/p&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;this will post the sum back and the Website will work without any blockage. You can easily try it.&lt;/p&gt;

&lt;h1 id="heading-things-to-remember-while-using-web-worker"&gt;Things to remember while using Web-Worker&lt;/h1&gt;

&lt;p&gt;Even though workers are amazing but there are some trade-offs which we will talk about in this Section.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;With great power come's the great Responsibility &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Web Workers use message passing which is performance costly. The message is copied instead of share which is exactly the reason for the performance cost.&lt;/p&gt;

&lt;p&gt;Let's use &lt;code&gt;performance.now()&lt;/code&gt; web API to get the performance of the same function in the main thread and web-worker thread and let's watch the performance.&lt;/p&gt;

&lt;p&gt;I changed the code according to our use case. Here are the new codes &lt;/p&gt;


&lt;pre&gt;&lt;code&gt;&lt;span class="hljs-comment"&gt;// main.js&lt;/span&gt;

&lt;p&gt;const calculateSum &lt;span&gt;=&lt;/span&gt; document.getElementById(&lt;span&gt;"calculateSum"&lt;/span&gt;);&lt;br&gt;
const changeColor &lt;span&gt;=&lt;/span&gt; document.getElementById(&lt;span&gt;"changeColor"&lt;/span&gt;);&lt;/p&gt;

&lt;p&gt;const worker &lt;span&gt;=&lt;/span&gt; &lt;span&gt;new&lt;/span&gt; Worker(&lt;span&gt;"worker.js"&lt;/span&gt;);&lt;/p&gt;

&lt;p&gt;threadedFunction &lt;span&gt;=&lt;/span&gt; () &lt;span&gt;=&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt; {&lt;br&gt;
  worker.postMessage({ text: &lt;span&gt;"sum"&lt;/span&gt; });&lt;/p&gt;

&lt;p&gt;worker.onmessage &lt;span&gt;=&lt;/span&gt; &lt;span&gt;&lt;span&gt;function&lt;/span&gt; (&lt;span&gt;e&lt;/span&gt;) &lt;/span&gt;{&lt;br&gt;
    &lt;span&gt;// document.getElementById("sum").innerHTML = &lt;code&gt;the sume is }&lt;/code&gt;;&lt;/span&gt;&lt;br&gt;
    worker.terminate();&lt;br&gt;
  };&lt;br&gt;
};&lt;/p&gt;

&lt;p&gt;MainThread &lt;span&gt;=&lt;/span&gt; () &lt;span&gt;=&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt; {&lt;br&gt;
  let start &lt;span&gt;=&lt;/span&gt; performance.now();&lt;br&gt;
  let sum &lt;span&gt;=&lt;/span&gt; &lt;span&gt;0&lt;/span&gt;;&lt;br&gt;
  let arr &lt;span&gt;=&lt;/span&gt; [];&lt;br&gt;
  &lt;span&gt;for&lt;/span&gt; (let i &lt;span&gt;=&lt;/span&gt; &lt;span&gt;0&lt;/span&gt;; i &lt;span&gt;&amp;lt;&lt;/span&gt; &lt;span&gt;10000&lt;/span&gt;; i&lt;span&gt;+&lt;/span&gt;&lt;span&gt;+&lt;/span&gt;) {&lt;br&gt;
    arr[i] &lt;span&gt;=&lt;/span&gt; i;&lt;br&gt;
  }&lt;br&gt;
  let end &lt;span&gt;=&lt;/span&gt; performance.now();&lt;br&gt;
  console.log(&lt;code&gt;Main thread took ${end &amp;lt;span class="hljs-operator"&amp;gt;-&amp;lt;/span&amp;gt; start} ms to complete&lt;/code&gt;);&lt;br&gt;
};&lt;/p&gt;

&lt;p&gt;calculateSum.addEventListener(&lt;span&gt;"click"&lt;/span&gt;, &lt;span&gt;&lt;span&gt;function&lt;/span&gt; (&lt;span&gt;&lt;/span&gt;) &lt;/span&gt;{&lt;br&gt;
  MainThread();&lt;br&gt;
  threadedFunction();&lt;br&gt;
});&lt;/p&gt;

&lt;p&gt;changeColor.addEventListener(&lt;span&gt;"click"&lt;/span&gt;, &lt;span&gt;&lt;span&gt;function&lt;/span&gt; (&lt;span&gt;&lt;/span&gt;) &lt;/span&gt;{&lt;br&gt;
  document.body.style.backgroundColor &lt;span&gt;=&lt;/span&gt;&lt;br&gt;
    document.body.style.backgroundColor &lt;span&gt;=&lt;/span&gt;&lt;span&gt;=&lt;/span&gt; &lt;span&gt;"red"&lt;/span&gt; ? &lt;span&gt;"blue"&lt;/span&gt; : &lt;span&gt;"red"&lt;/span&gt;;&lt;br&gt;
});&lt;br&gt;
&lt;/p&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;&lt;span class="hljs-comment"&gt;// worker.js&lt;/span&gt;

&lt;p&gt;onmessage &lt;span&gt;=&lt;/span&gt; (e) &lt;span&gt;=&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt; {&lt;br&gt;
  let start &lt;span&gt;=&lt;/span&gt; performance.now();&lt;br&gt;
  let arr &lt;span&gt;=&lt;/span&gt; [];&lt;br&gt;
  let sum &lt;span&gt;=&lt;/span&gt; &lt;span&gt;0&lt;/span&gt;;&lt;br&gt;
  &lt;span&gt;for&lt;/span&gt; (let i &lt;span&gt;=&lt;/span&gt; &lt;span&gt;0&lt;/span&gt;; i &lt;span&gt;&amp;lt;&lt;/span&gt; &lt;span&gt;10000&lt;/span&gt;; i&lt;span&gt;+&lt;/span&gt;&lt;span&gt;+&lt;/span&gt;) {&lt;br&gt;
    arr[i] &lt;span&gt;=&lt;/span&gt; i;&lt;br&gt;
  }&lt;br&gt;
  postMessage(arr);&lt;br&gt;
  let end &lt;span&gt;=&lt;/span&gt; performance.now();&lt;br&gt;
  console.log(&lt;code&gt;Worker took ${end &amp;lt;span class="hljs-operator"&amp;gt;-&amp;lt;/span&amp;gt; start} ms to complete&lt;/code&gt;);&lt;br&gt;
};&lt;br&gt;
&lt;/p&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Here are the results for the above benchmarks on my Pc with an i7 processor.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KgpwOuhe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1660503911754/8qx3akRIQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KgpwOuhe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1660503911754/8qx3akRIQ.png" alt="image.png" width="880" height="119"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Well, this might come as a shock to you because we are actually running the same code than why it is almost 2x slow.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--SdAkIhmr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1660523647501/x6EFWgPQ_.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SdAkIhmr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1660523647501/x6EFWgPQ_.png" alt="image.png" width="582" height="470"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2 id="heading-debugging-the-performance"&gt;Debugging the Performance&lt;/h2&gt;

&lt;p&gt;Let's use the performance profiler to actually see what is taking so long for it to execute the same program in the worker thread.&lt;/p&gt;

&lt;p&gt;As you can see the message takes almost 0.5ms whereas the original function call only took 1.5ms. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--A8w9N1AT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1660504475768/4WJjjIKgy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--A8w9N1AT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1660504475768/4WJjjIKgy.png" alt="OnMesage Time" width="880" height="102"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--e8XJgJ4v--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1660504492117/d3yqd3pBc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--e8XJgJ4v--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1660504492117/d3yqd3pBc.png" alt="Function Call" width="858" height="124"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In Web Worker the more complex the data you pass the more time it will take to pass as it copies the whole data.&lt;/p&gt;

&lt;p&gt;There are various ways to optimize the performance which we will talk about in the next session.&lt;/p&gt;

&lt;h1 id="heading-tldr"&gt;TL;DR&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt;Javascript is a Single Threaded Language but you can use multithreading in javascript using web-workers in the browser.&lt;/li&gt;
&lt;li&gt;Web-Workers are easily initiated using &lt;code&gt;new Worker()&lt;/code&gt; and you can pass data from the main thread and worker thread using &lt;code&gt;onmessage()&lt;/code&gt; method and &lt;code&gt;postMessage()&lt;/code&gt; method.&lt;/li&gt;
&lt;li&gt;Complex Data takes more time to pass as workers do not share the data but instead copy them.&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;This blog is posted using &lt;a href="https://blogtiple.com"&gt;Blogtiple&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>performance</category>
      <category>webdev</category>
      <category>designpatterns</category>
    </item>
    <item>
      <title>Creating a React Modal with React custom Hooks and Typescript</title>
      <dc:creator>Ashish maurya</dc:creator>
      <pubDate>Sun, 07 Aug 2022 14:54:01 +0000</pubDate>
      <link>https://forem.com/theashishmaurya/creating-a-react-modal-with-react-custom-hooks-and-typescript-55ma</link>
      <guid>https://forem.com/theashishmaurya/creating-a-react-modal-with-react-custom-hooks-and-typescript-55ma</guid>
      <description>&lt;p&gt;Hello Guys,&lt;/p&gt;

&lt;p&gt;React hooks are very useful features of React and with this comes custom React hooks, these custom React hooks have endless possibilities and can easily replace container Logic in Container/Presentational Model.&lt;/p&gt;

&lt;p&gt;Read more about that here &lt;a href="https://www.patterns.dev/posts/#design-patterns"&gt;Patter.dev&lt;/a&gt;&lt;/p&gt;

&lt;h1 id="heading-creating-the-modal-from-scratch"&gt;Creating the Modal from Scratch&lt;/h1&gt;

&lt;h2 id="heading-creating-the-presentational-part-of-modal"&gt;Creating the Presentational Part of Modal&lt;/h2&gt;

&lt;p&gt;Let's create the presentational part of the  Modal in this I will be quick and just show you the code &lt;/p&gt;


&lt;pre&gt;&lt;code&gt;&lt;span class="hljs-keyword"&gt;import&lt;/span&gt; &lt;span class="hljs-title"&gt;React&lt;/span&gt;, { &lt;span class="hljs-title"&gt;ReactNode&lt;/span&gt; } &lt;span class="hljs-title"&gt;&lt;span&gt;from&lt;/span&gt;&lt;/span&gt; &lt;span class="hljs-string"&gt;"react"&lt;/span&gt;;

&lt;p&gt;&lt;span&gt;&lt;span&gt;interface&lt;/span&gt; &lt;span&gt;ModalType&lt;/span&gt; &lt;/span&gt;{&lt;br&gt;
  children?: ReactNode;&lt;br&gt;
  isOpen: boolean;&lt;br&gt;
  toggle: () &lt;span&gt;=&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt; void;&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;export default &lt;span&gt;&lt;span&gt;function&lt;/span&gt; &lt;span&gt;Modal&lt;/span&gt;(&lt;span&gt;props: ModalType&lt;/span&gt;) &lt;/span&gt;{&lt;br&gt;
  &lt;span&gt;return&lt;/span&gt; (&lt;br&gt;
    &lt;span&gt;&amp;lt;&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;
        &lt;span&gt;&amp;lt;&lt;/span&gt;div className&lt;span&gt;=&lt;/span&gt;&lt;span&gt;"modal-overlay"&lt;/span&gt; &lt;span&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;
          &lt;span&gt;&amp;lt;&lt;/span&gt;div  className&lt;span&gt;=&lt;/span&gt;&lt;span&gt;"modal-box"&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;
            {props.children}&lt;br&gt;
          &lt;span&gt;&amp;lt;&lt;/span&gt;&lt;span&gt;/&lt;/span&gt;div&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;
        &lt;span&gt;&amp;lt;&lt;/span&gt;&lt;span&gt;/&lt;/span&gt;div&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;
    &lt;span&gt;&amp;lt;&lt;/span&gt;&lt;span&gt;/&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;
  );&lt;br&gt;
}&lt;br&gt;
&lt;/p&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;let me explain this to you, So here we have two div an &lt;code&gt;overlay-div&lt;/code&gt; which have full width and height, and a &lt;code&gt;modal-box div&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;So we are trying to achieve something like below where if the user clicks anywhere else than the &lt;code&gt;modal-box div&lt;/code&gt; the modal will get closed. And all the modal content will be inside the white part of the modal.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HILlVq4V--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1659644607856/IjCMklBHB.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HILlVq4V--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1659644607856/IjCMklBHB.png" alt="image.png" width="522" height="492"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;let's quickly set up the CSS for our modal divs.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;&lt;br&gt;
&lt;span class="hljs-selector-class"&gt;.modal-overlay&lt;/span&gt; {&lt;br&gt;
  &lt;span class="hljs-attribute"&gt;z-index&lt;/span&gt;: &lt;span class="hljs-number"&gt;9999&lt;/span&gt;;&lt;br&gt;
  &lt;span class="hljs-attribute"&gt;width&lt;/span&gt;: &lt;span class="hljs-number"&gt;100vw&lt;/span&gt;;&lt;br&gt;
  &lt;span class="hljs-attribute"&gt;height&lt;/span&gt;: &lt;span class="hljs-number"&gt;100vh&lt;/span&gt;;&lt;br&gt;
  &lt;span class="hljs-attribute"&gt;position&lt;/span&gt;: absolute;&lt;br&gt;
  &lt;span class="hljs-attribute"&gt;top&lt;/span&gt;: &lt;span class="hljs-number"&gt;0&lt;/span&gt;;&lt;br&gt;
  &lt;span class="hljs-attribute"&gt;background&lt;/span&gt;: &lt;span class="hljs-built_in"&gt;rgba&lt;/span&gt;(&lt;span class="hljs-number"&gt;0&lt;/span&gt;, &lt;span class="hljs-number"&gt;0&lt;/span&gt;, &lt;span class="hljs-number"&gt;0&lt;/span&gt;, &lt;span class="hljs-number"&gt;0.7&lt;/span&gt;);&lt;br&gt;
  &lt;span class="hljs-attribute"&gt;display&lt;/span&gt;: flex;&lt;br&gt;
  &lt;span class="hljs-attribute"&gt;justify-content&lt;/span&gt;: center;&lt;br&gt;
  &lt;span class="hljs-attribute"&gt;align-items&lt;/span&gt;: center;&lt;br&gt;
}

&lt;p&gt;&lt;span&gt;.modal-box&lt;/span&gt; {&lt;br&gt;
  &lt;span&gt;display&lt;/span&gt;: block;&lt;br&gt;
  &lt;span&gt;background&lt;/span&gt;: white;&lt;br&gt;
  &lt;span&gt;width&lt;/span&gt;: &lt;span&gt;70%&lt;/span&gt;;&lt;br&gt;
  &lt;span&gt;height&lt;/span&gt;: &lt;span&gt;70%&lt;/span&gt;;&lt;br&gt;
  &lt;span&gt;padding&lt;/span&gt;: &lt;span&gt;1rem&lt;/span&gt;;&lt;br&gt;
  &lt;span&gt;border-radius&lt;/span&gt;: &lt;span&gt;1rem&lt;/span&gt;;&lt;br&gt;
}&lt;br&gt;
&lt;/p&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;once this is done we need will get to our logic part where we will only render the Modal if our state is true. &lt;/p&gt;

&lt;h2 id="heading-why-custom-hook"&gt;Why custom Hook?&lt;/h2&gt;

&lt;p&gt;Here I used a custom hook so that I don't have to write the same logic again and again when trying to use modal and add the same function in all the files.&lt;/p&gt;

&lt;h2 id="heading-adding-logic-to-the-hooks"&gt;Adding logic to the Hooks&lt;/h2&gt;

&lt;p&gt;let's quickly make a new file &lt;code&gt;useModal.tsx&lt;/code&gt; in our &lt;code&gt;hooks&lt;/code&gt; folder this will be a pure function and only contain the logic for now.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;&lt;span class="hljs-comment"&gt;// useModal.tsx&lt;/span&gt;

&lt;p&gt;&lt;span&gt;import&lt;/span&gt; { &lt;span&gt;useState&lt;/span&gt; } &lt;span&gt;&lt;span&gt;from&lt;/span&gt;&lt;/span&gt; &lt;span&gt;"react"&lt;/span&gt;;&lt;/p&gt;

&lt;p&gt;export default &lt;span&gt;&lt;span&gt;function&lt;/span&gt; &lt;span&gt;useModal&lt;/span&gt;(&lt;span&gt;&lt;/span&gt;) &lt;/span&gt;{&lt;br&gt;
  const [isOpen, setisOpen] &lt;span&gt;=&lt;/span&gt; useState(&lt;span&gt;false&lt;/span&gt;);&lt;/p&gt;

&lt;p&gt;const toggle &lt;span&gt;=&lt;/span&gt; () &lt;span&gt;=&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt; {&lt;br&gt;
    setisOpen(&lt;span&gt;!&lt;/span&gt;isOpen);&lt;br&gt;
  };&lt;/p&gt;

&lt;p&gt;&lt;span&gt;return&lt;/span&gt; {&lt;br&gt;
    isOpen,&lt;br&gt;
    toggle&lt;br&gt;
  };&lt;br&gt;
}&lt;br&gt;
&lt;/p&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In this, we have a state &lt;code&gt;isOpen&lt;/code&gt; to show or hide the modal, and then there is a function that actually toggles the visibility of the Modal.&lt;/p&gt;

&lt;p&gt;now let's use this code in our &lt;code&gt;App.tsx&lt;/code&gt; and implement a Modal that gets triggered on click&lt;/p&gt;

&lt;h2 id="heading-combining-the-logic-and-presentational-part-hooks-modal-component"&gt;Combining the logic and Presentational Part ( hooks + Modal component)&lt;/h2&gt;

&lt;h3 id="heading-calling-the-modal-component-and-usemodal"&gt;Calling the Modal component and useModal&lt;/h3&gt;

&lt;p&gt;let's import out the Modal component and &lt;code&gt;useModal&lt;/code&gt; hook in &lt;code&gt;App.tsx&lt;/code&gt; &lt;/p&gt;


&lt;pre&gt;&lt;code&gt;&lt;span class="hljs-keyword"&gt;import&lt;/span&gt; &lt;span class="hljs-title"&gt;Modal&lt;/span&gt; &lt;span class="hljs-title"&gt;&lt;span&gt;from&lt;/span&gt;&lt;/span&gt; &lt;span class="hljs-string"&gt;"./component/modal"&lt;/span&gt;;&lt;br&gt;
&lt;span class="hljs-keyword"&gt;import&lt;/span&gt; &lt;span class="hljs-title"&gt;useModal&lt;/span&gt; &lt;span class="hljs-title"&gt;&lt;span&gt;from&lt;/span&gt;&lt;/span&gt; &lt;span class="hljs-string"&gt;"../src/hooks/useModal"&lt;/span&gt;;&lt;br&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;let's add the other logic and pass &lt;code&gt;isOpen&lt;/code&gt; and &lt;code&gt;toggle&lt;/code&gt; to the &lt;code&gt;Modal&lt;/code&gt; component.&lt;/p&gt;

&lt;p&gt;our &lt;code&gt;App.tsx&lt;/code&gt; will look something like below&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;export default &lt;span class="hljs-function"&gt;&lt;span&gt;function&lt;/span&gt; &lt;span&gt;App&lt;/span&gt;(&lt;span&gt;&lt;/span&gt;) &lt;/span&gt;{&lt;br&gt;
  const { isOpen, toggle } &lt;span class="hljs-operator"&gt;=&lt;/span&gt; useModal();&lt;br&gt;
  &lt;span class="hljs-keyword"&gt;return&lt;/span&gt; (&lt;br&gt;
    &lt;span class="hljs-operator"&gt;&amp;lt;&lt;/span&gt;div className&lt;span class="hljs-operator"&gt;=&lt;/span&gt;&lt;span class="hljs-string"&gt;"App"&lt;/span&gt;&lt;span class="hljs-operator"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;
      &lt;span class="hljs-operator"&gt;&amp;lt;&lt;/span&gt;h1&lt;span class="hljs-operator"&gt;&amp;gt;&lt;/span&gt;Hello CodeSandbox&lt;span class="hljs-operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="hljs-operator"&gt;/&lt;/span&gt;h1&lt;span class="hljs-operator"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;
      &lt;span class="hljs-operator"&gt;&amp;lt;&lt;/span&gt;h2&lt;span class="hljs-operator"&gt;&amp;gt;&lt;/span&gt;Start editing to see some magic happen&lt;span class="hljs-operator"&gt;!&lt;/span&gt;&lt;span class="hljs-operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="hljs-operator"&gt;/&lt;/span&gt;h2&lt;span class="hljs-operator"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;
      &lt;span class="hljs-operator"&gt;&amp;lt;&lt;/span&gt;button onClick&lt;span class="hljs-operator"&gt;=&lt;/span&gt;{toggle}&lt;span class="hljs-operator"&gt;&amp;gt;&lt;/span&gt;Open Modal &lt;span class="hljs-operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="hljs-operator"&gt;/&lt;/span&gt;button&lt;span class="hljs-operator"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;
      &lt;span class="hljs-operator"&gt;&amp;lt;&lt;/span&gt;Modal isOpen&lt;span class="hljs-operator"&gt;=&lt;/span&gt;{isOpen} toggle&lt;span class="hljs-operator"&gt;=&lt;/span&gt;{toggle}&lt;span class="hljs-operator"&gt;&amp;gt;&lt;/span&gt;&lt;span class="hljs-operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="hljs-operator"&gt;/&lt;/span&gt;Modal&lt;span class="hljs-operator"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;
    &lt;span class="hljs-operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="hljs-operator"&gt;/&lt;/span&gt;div&lt;span class="hljs-operator"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;
  );&lt;br&gt;
}&lt;br&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id="heading-adding-logic-to-modal-component"&gt;Adding Logic to Modal component&lt;/h3&gt;

&lt;p&gt;Well at this point we are almost done all we need is to add some basic conditional rendering logic to our Modal component and let's see what we have.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;&lt;span class="hljs-comment"&gt;// Modal.tsx&lt;/span&gt;

&lt;p&gt;&lt;span&gt;import&lt;/span&gt; &lt;span&gt;React&lt;/span&gt;, { &lt;span&gt;ReactNode&lt;/span&gt; } &lt;span&gt;&lt;span&gt;from&lt;/span&gt;&lt;/span&gt; &lt;span&gt;"react"&lt;/span&gt;;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;&lt;span&gt;interface&lt;/span&gt; &lt;span&gt;ModalType&lt;/span&gt; &lt;/span&gt;{&lt;br&gt;
  children?: ReactNode;&lt;br&gt;
  isOpen: boolean;&lt;br&gt;
  toggle: () &lt;span&gt;=&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt; void;&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;export default &lt;span&gt;&lt;span&gt;function&lt;/span&gt; &lt;span&gt;Modal&lt;/span&gt;(&lt;span&gt;props: ModalType&lt;/span&gt;) &lt;/span&gt;{&lt;br&gt;
  &lt;span&gt;return&lt;/span&gt; (&lt;br&gt;
    &lt;span&gt;&amp;lt;&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;
      {props.isOpen &lt;span&gt;&amp;amp;&lt;/span&gt;&lt;span&gt;&amp;amp;&lt;/span&gt; (&lt;br&gt;
        &lt;span&gt;&amp;lt;&lt;/span&gt;div className&lt;span&gt;=&lt;/span&gt;&lt;span&gt;"modal-overlay"&lt;/span&gt; onClick&lt;span&gt;=&lt;/span&gt;{props.toggle}&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;
          &lt;span&gt;&amp;lt;&lt;/span&gt;div  className&lt;span&gt;=&lt;/span&gt;&lt;span&gt;"modal-box"&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;
            {props.children}&lt;br&gt;
          &lt;span&gt;&amp;lt;&lt;/span&gt;&lt;span&gt;/&lt;/span&gt;div&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;
        &lt;span&gt;&amp;lt;&lt;/span&gt;&lt;span&gt;/&lt;/span&gt;div&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;
      )}&lt;br&gt;
    &lt;span&gt;&amp;lt;&lt;/span&gt;&lt;span&gt;/&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;
  );&lt;br&gt;
}&lt;br&gt;
&lt;/p&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;we added the onClick event and passed the &lt;code&gt;toggle&lt;/code&gt; function to it so that if we click anywhere else on the outside of the modal, the modal get's close.&lt;/p&gt;

&lt;p&gt;Also, we rendered our component such that if &lt;code&gt;isOpen = false&lt;/code&gt; it will return nothing.&lt;/p&gt;

&lt;p&gt;At this point we are done let's see how it looks now.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--aND2nASG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1659645825205/PyuaqONbo.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--aND2nASG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1659645825205/PyuaqONbo.gif" alt="CPT2208050212-632x542.gif" width="632" height="542"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now it's working fine .......... Well Almost actually.&lt;/p&gt;

&lt;p&gt;if you noticed if we click on the inner div even then the whole modal is getting close which is not something we can do as this can lead to several issues. &lt;/p&gt;

&lt;p&gt;This is happening due to the phenomenon called Event Bubbling in Javascript where any event is propagated through the parent divs.&lt;/p&gt;

&lt;h1 id="heading-solving-bugs-and-handling-event-propagation"&gt;Solving bugs and handling Event Propagation.&lt;/h1&gt;

&lt;p&gt;In React this can be easily solved by the using &lt;code&gt;event.stopPropagation()&lt;/code&gt; method which is already provided by React.&lt;/p&gt;

&lt;p&gt;We will just call this method when the user clicks on the Inner div.&lt;/p&gt;

&lt;p&gt;let's see how our code looks now&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;&lt;span class="hljs-comment"&gt;// Modal.tsx&lt;/span&gt;

&lt;p&gt;&lt;span&gt;import&lt;/span&gt; &lt;span&gt;React&lt;/span&gt;, { &lt;span&gt;ReactNode&lt;/span&gt; } &lt;span&gt;&lt;span&gt;from&lt;/span&gt;&lt;/span&gt; &lt;span&gt;"react"&lt;/span&gt;;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;&lt;span&gt;interface&lt;/span&gt; &lt;span&gt;ModalType&lt;/span&gt; &lt;/span&gt;{&lt;br&gt;
  children?: ReactNode;&lt;br&gt;
  isOpen: boolean;&lt;br&gt;
  toggle: () &lt;span&gt;=&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt; void;&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;export default &lt;span&gt;&lt;span&gt;function&lt;/span&gt; &lt;span&gt;Modal&lt;/span&gt;(&lt;span&gt;props: ModalType&lt;/span&gt;) &lt;/span&gt;{&lt;br&gt;
  &lt;span&gt;return&lt;/span&gt; (&lt;br&gt;
    &lt;span&gt;&amp;lt;&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;
      {props.isOpen &lt;span&gt;&amp;amp;&lt;/span&gt;&lt;span&gt;&amp;amp;&lt;/span&gt; (&lt;br&gt;
        &lt;span&gt;&amp;lt;&lt;/span&gt;div className&lt;span&gt;=&lt;/span&gt;&lt;span&gt;"modal-overlay"&lt;/span&gt; onClick&lt;span&gt;=&lt;/span&gt;{props.toggle}&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;
          &lt;span&gt;&amp;lt;&lt;/span&gt;div onClick&lt;span&gt;=&lt;/span&gt;{(e) &lt;span&gt;=&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt; e.stopPropagation()} className&lt;span&gt;=&lt;/span&gt;&lt;span&gt;"modal-box"&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;
            {props.children}&lt;br&gt;
          &lt;span&gt;&amp;lt;&lt;/span&gt;&lt;span&gt;/&lt;/span&gt;div&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;
        &lt;span&gt;&amp;lt;&lt;/span&gt;&lt;span&gt;/&lt;/span&gt;div&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;
      )}&lt;br&gt;
    &lt;span&gt;&amp;lt;&lt;/span&gt;&lt;span&gt;/&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;
  );&lt;br&gt;
}&lt;br&gt;
&lt;/p&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Yaay !!!!!!!!!! now the above problem is solved&lt;/p&gt;

&lt;h1 id="heading-try-this-on-sandbox"&gt;Try this on Sandbox?&lt;/h1&gt;

&lt;p&gt;Hope you like testing it try adding more features to it.&lt;/p&gt;

&lt;h1 id="heading-tldr"&gt;TL;DR&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;We learned about container/presentational design patter&lt;/li&gt;
&lt;li&gt;We learned how to create our own custom hooks and separate all the logic parts from the UI.&lt;/li&gt;
&lt;li&gt;We learned how the Modal component works and to create reusable React component&lt;/li&gt;
&lt;li&gt;We learned what is event propagation and how to stop it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;if you like this post let's get connected on Twitter:&lt;/p&gt;

&lt;p&gt; &lt;a href="https://twitter.com/theysaymaurya"&gt;Follow me here&lt;/a&gt;&lt;/p&gt;


&lt;p&gt;This blog is posted using &lt;a href="https://blogtiple.com"&gt;Blogtiple&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>typescript</category>
      <category>javascript</category>
      <category>designpatterns</category>
    </item>
    <item>
      <title>Testing For Project submission</title>
      <dc:creator>Ashish maurya</dc:creator>
      <pubDate>Wed, 27 Apr 2022 08:11:02 +0000</pubDate>
      <link>https://forem.com/theashishmaurya/testing-for-project-submission-142f</link>
      <guid>https://forem.com/theashishmaurya/testing-for-project-submission-142f</guid>
      <description>&lt;p&gt;Hey,
Testing to project submission.&lt;/p&gt;


&lt;p&gt;This blog is posted using &lt;a href="https://blogtiple.com"&gt;Blogtiple&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Setting Up Your Online Store: The Gumroad Way</title>
      <dc:creator>Ashish maurya</dc:creator>
      <pubDate>Sat, 26 Mar 2022 08:32:00 +0000</pubDate>
      <link>https://forem.com/theashishmaurya/setting-up-your-online-store-the-gumroad-way-1c9b</link>
      <guid>https://forem.com/theashishmaurya/setting-up-your-online-store-the-gumroad-way-1c9b</guid>
      <description>&lt;p&gt;Well, Lately I have been trying to build some source of income where I have to work once and get paid for the product instead of the hourly paid. Most people call it a passive income stream. In my research and exploring through countless youtube videos I got to the conclusion that selling online stuff would be the best way for me right now.&lt;/p&gt;

&lt;h1 id="heading-finding-your-niche"&gt;Finding your Niche&lt;/h1&gt;

&lt;p&gt;Well selling online is cool but what am I supposed to sell that was a big problem for me to find out what I am good at and what can make money.
As I am good at making websites and Designs I thought why not sell React Templates for different purposes.&lt;/p&gt;

&lt;p&gt;For each person, it could be anything.&lt;/p&gt;

&lt;h1 id="heading-finding-the-platform-to-sell"&gt;Finding the platform to Sell&lt;/h1&gt;

&lt;p&gt;Now that I found the product I wanted to sell the big question was where to sell?&lt;/p&gt;

&lt;p&gt;After a couple of searches, I got to find three good platforms to sell at.&lt;/p&gt;

&lt;h3 id="heading-already-built-market-places"&gt;Already Built Market Places&lt;/h3&gt;

&lt;p&gt;Build Market places are good but I think that they have a lot of sellers and are already saturated with them. For my needs, I needed something new and creative. That's where Gumroad comes to the rescue. &lt;/p&gt;

&lt;h3 id="heading-setting-up-youre-a-custom-shop-on-your-own-domain"&gt;Setting up you're a custom shop on your own domain&lt;/h3&gt;

&lt;p&gt;Setting up your own custom store can be challenging for a non-tech person and even for a tech person handling all the transactions and databases is a pain if you don't already know that you selling.&lt;/p&gt;

&lt;p&gt;Well in my case I thought of this but eventually, drop it as it can be a lot of process and work.&lt;/p&gt;

&lt;h3 id="heading-gumroad-my-choice"&gt;Gumroad ( My choice)&lt;/h3&gt;

&lt;p&gt;Well, I have been seeing a lot of developers and Influencers selling their product on Gumroad and the got me curious so I tried to explore Gumroad and I find this can be the right choice for my need as I don't have to write all the code and won't be handling the payment gateway and stuff. So that my prime focus will be on the selling and product.&lt;/p&gt;

&lt;p&gt;Well, Gumroad is fine but I really wanted some traffic to my domain so after exploring I got to know I can set up my custom domain to the Gumroad same as I have set this blog to my domain.
So instead of users being redirected to gumroad.com/@username they will be redirected to store.theashishmaurya.me.&lt;/p&gt;

&lt;h1 id="heading-setting-up-your-custom-domain-with-gumroad"&gt;Setting Up your custom domain with Gumroad.&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt;Once you are logged in to the Gumroad go to the setting &amp;gt;&amp;gt; Advance setting then put store.yourdomain.com in the domain or whatever you want to.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3RrsAjj2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1647761651205/ZaEqoLAFs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3RrsAjj2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1647761651205/ZaEqoLAFs.png" alt="image.png" width="880" height="433"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Before verifying you need to add the CNAME to your domain provider. In my case, I m using Netlify so my configuration looks something like this.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--LMyponWI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1647761809080/blLDWzIQs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LMyponWI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1647761809080/blLDWzIQs.png" alt="image.png" width="880" height="76"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Also if you don't know how to set up a custom domain in Netlify read the below article of mine, the process is quite similar.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://blog.theashishmaurya.me/how-to-integrate-your-hashnode-blog-with-netlify"&gt;&lt;/a&gt;&lt;a href="https://blog.theashishmaurya.me/how-to-integrate-your-hashnode-blog-with-netlify"&gt;https://blog.theashishmaurya.me/how-to-integrate-your-hashnode-blog-with-netlify&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once you are all set up click on verify in your Gumroad setting and you will get a confirmation like below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--f3FW_Nm_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1647761977759/G1Ync_BZG.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--f3FW_Nm_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1647761977759/G1Ync_BZG.png" alt="image.png" width="880" height="144"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Read more about the domain setup here https://help.gumroad.com/article/153-setting-up-a-custom-domain&lt;/p&gt;

&lt;h1 id="heading-the-result"&gt;The Result&lt;/h1&gt;

&lt;p&gt;You are all set up to sell things online now. It might take 24 hours for the domain to reflect changes but once it is done you will have something like this on the link.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Ewf7FJVc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1647762084111/iOYwlLhhG.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ewf7FJVc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1647762084111/iOYwlLhhG.png" alt="image.png" width="880" height="431"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Keep selling!! Also, follow me and subscribe to me so that you can get more updates like this.&lt;/p&gt;


&lt;p&gt;This blog is posted using &lt;a href="https://blogtiple.com"&gt;Blogtiple&lt;/a&gt;&lt;/p&gt;

</description>
      <category>marketing</category>
      <category>guide</category>
      <category>developer</category>
      <category>monetization</category>
    </item>
    <item>
      <title>Introducing Blogtiple - A Cross Blogging Application</title>
      <dc:creator>Ashish maurya</dc:creator>
      <pubDate>Sun, 20 Mar 2022 03:52:24 +0000</pubDate>
      <link>https://forem.com/theashishmaurya/introducing-blogtiple-a-cross-blogging-application-59ej</link>
      <guid>https://forem.com/theashishmaurya/introducing-blogtiple-a-cross-blogging-application-59ej</guid>
      <description>&lt;h1 id="heading-introduction"&gt;Introduction&lt;/h1&gt;

&lt;p&gt;Hey Folks, If you are into blogging well then this product is a treat for you guys, so pay attention to this blog. &lt;/p&gt;

&lt;p&gt;Have you ever wondered why do you even write blogs? Is it to share the information or to grow as a blogger? Well, whatever the reason it might be I got your back with Blogtiple. &lt;/p&gt;

&lt;p&gt;But how? you ask.&lt;/p&gt;

&lt;p&gt;Hmmm! good question, before I answer that let me tell you what is the major problem I solved with this product. &lt;/p&gt;

&lt;h1 id="heading-the-problem"&gt;The Problem&lt;/h1&gt;

&lt;p&gt;After getting into this Tech blogging world I realized one thing there are a lot of other blogging websites except Hashnode and Dev.to and the one other realization was that the more you post on each and every platforms the more audience and exposure you will have. This can also mean more leads for your next freelancing gig or maybe more recognization and if you are the second type who just want to share their blog post isn't it better the more people are now reading your blogs across the other Platforms?&lt;/p&gt;

&lt;p&gt;But it's obvious to most of the users and they already post it to other platforms too. But, personally copying and pasting everything, it's a drag for me.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VO88c7xM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1645781346321/oFgCCGB7J.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VO88c7xM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1645781346321/oFgCCGB7J.png" alt="image.png" width="313" height="234"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I can't copy and paste all my content across every other platform its too much work. So what's the solution?&lt;/p&gt;

&lt;h1 id="heading-the-idea-behind-blogtiple"&gt;The Idea Behind Blogtiple&lt;/h1&gt;

&lt;p&gt; I thought to create a pipeline/system which can automatically import my already written blogs and post them to other blogging platforms. Well, that's what Blogtiple does for you all you need is to select the provider and Copy paste the link of your blog, and click post.&lt;/p&gt;

&lt;p&gt;Cool and comfy isn't it?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://giphy.com/gifs/badass-boye-kiBcwEXegBTACmVOnE"&gt;via GIPHY&lt;/a&gt;&lt;/p&gt; 

&lt;h1 id="heading-features"&gt;Features&lt;/h1&gt;

&lt;h3 id="heading-importing-your-already-written-blogs"&gt;Importing your already written blogs.&lt;/h3&gt;

&lt;p&gt;This is one of the core features we offer and the flow works something like below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--g7A4ezWi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1645975042265/3qSk2Nfge.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--g7A4ezWi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1645975042265/3qSk2Nfge.png" alt="image.png" width="880" height="495"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see the user is providing a URL and Provider for their blog, after that, we fetch that blog either from Dev, Medium, or Hashnode depending on the provider, and then post it to other platforms.&lt;/p&gt;

&lt;p&gt;Till now we are only supporting Medium, Hashnode, and DEV but planning to add more as we grow.&lt;/p&gt;

&lt;h3 id="heading-scheduling-blogs-for-later-beta"&gt;Scheduling Blogs for later  (Beta)&lt;/h3&gt;

&lt;p&gt;It's another amazing feature of this App, Say you want your blogs to be posted on different days on different platforms. You can easily schedule your posts on the days you like and I will be posted on them.&lt;/p&gt;

&lt;p&gt;This feature is using Netlify's function's cron job which was released this month only.&lt;/p&gt;

&lt;p&gt;Watch this video to understand more about the scheduling function on Netlify&lt;/p&gt;

&lt;p&gt;The flow for the Scheduling works something Like this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xvpumDAl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1645976201620/gyuyhiGl8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xvpumDAl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1645976201620/gyuyhiGl8.png" alt="image.png" width="880" height="495"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Other Features to be Included Are&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Advance Analytics to keep track of all the blogs across all Platforms.&lt;/li&gt;
&lt;li&gt;A Better markdown editor with Image and gifs and emoji integration support.&lt;/li&gt;
&lt;li&gt;New platforms&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id="heading-demo"&gt;Demo&lt;/h1&gt;

&lt;h2 id="heading-posting-directly-to-platforms"&gt;Posting Directly to Platforms&lt;/h2&gt;

&lt;p&gt;Let me show you how to post your blogs from Hashnode to other platforms i.e Dev and Medium.&lt;/p&gt;

&lt;p&gt;I wrote a test Blog on the Hashnode here it is &lt;/p&gt;

&lt;p&gt;&lt;a href="https://blog.theashishmaurya.me/testing-blogtiple"&gt;&lt;/a&gt;&lt;a href="https://blog.theashishmaurya.me/testing-blogtiple"&gt;https://blog.theashishmaurya.me/testing-blogtiple&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now let's get started&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--n32lQauF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646029368851/XSEPXdjNW.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--n32lQauF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646029368851/XSEPXdjNW.png" alt="image.png" width="880" height="439"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Let's log in, I will be using google provider for login.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--I5FZ1ACP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646029465016/0KZGgKxbd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--I5FZ1ACP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646029465016/0KZGgKxbd.png" alt="image.png" width="880" height="744"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Once you are logged in you will be seeing the Import blog page and will be something like below&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--i9CNPx2v--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646029683674/lw2Z_JCqq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--i9CNPx2v--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646029683674/lw2Z_JCqq.png" alt="image.png" width="880" height="441"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Goto setting and add the API keys for the platforms. Just so you know the keys are encrypted once they leave your browser so even I can't use it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--M-Ds7hqF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646029845993/ZGnruO1NZ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--M-Ds7hqF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646029845993/ZGnruO1NZ.png" alt="image.png" width="880" height="438"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Now save each of the keys and go to the Import option.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;In Import Page Select the Provider to Hashnode and paste the link and then click on the fetch to fetch any blog you want.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;I will be fetching my test blog&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7hUhqF5R--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646029965672/CST0RZysD.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7hUhqF5R--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646029965672/CST0RZysD.png" alt="image.png" width="880" height="438"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;As you can see that it is fetched and displayed in the blog display Area.&lt;/li&gt;
&lt;/ul&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Now let's select where we want to post and select put the original link as Canonical link. (It's important to put Canonical link)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You can also add some Tags too if you like.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nawy7FxO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646030213955/ZlV5TDds8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nawy7FxO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646030213955/ZlV5TDds8.png" alt="image.png" width="880" height="439"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Now you are all set to post these blogs to the other platform.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id="heading-results"&gt;Results&lt;/h3&gt;

&lt;p&gt;Here we get the post to Dev.to and Medium&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Dev.to&lt;/strong&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--S9tulVjp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646030312856/JFWSvg3dr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--S9tulVjp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646030312856/JFWSvg3dr.png" alt="image.png" width="870" height="252"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Medium&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cc1bXjeT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646030350431/AkPvqvXQ2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cc1bXjeT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646030350431/AkPvqvXQ2.png" alt="image.png" width="880" height="147"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2 id="heading-scheduling-for-later"&gt;Scheduling for Later&lt;/h2&gt;

&lt;p&gt;Instead of posting directly, we can also schedule posts for later &lt;/p&gt;

&lt;p&gt;Just instead of clicking on Post just click on Schedule and then select the date you want to post to.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BUeRHxm6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646030659726/PJ-N23BZV.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BUeRHxm6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1646030659726/PJ-N23BZV.png" alt="image.png" width="880" height="440"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1 id="heading-video-demo"&gt;Video Demo&lt;/h1&gt;



&lt;h1 id="heading-role-of-netlify"&gt;Role of Netlify&lt;/h1&gt;

&lt;p&gt;Here Netlify plays a crucial role, from hosting Blogtiple to triggering the scheduled functions by using Netlify functions for cron jobs. It is a crucial part of the scheduling feature and using Netlify functions solved a lot of problems and complexity I would have to deal with and efforts for writing my own cron job functions.&lt;/p&gt;

&lt;h1 id="heading-challenges"&gt;Challenges&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;The major challenge was to import blogs from Medium, as Medium does not support any fetch API for the user blog and only supports post API. The workaround was a hard job and the tradeoff was the time complexity increased a lot.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Second major challenge was to find a good way to trigger functions for scheduling as firebase function was my first choice but they are not free for use, hence I needed to find something else after some research luckily I got to know that Netlify has just launched cron job function this month and the timing couldn't be more perfect for me.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Also to ask users to give the API key for posting blogs to their blog still feels a lot, So I thought why not encrypt the API keys before they leave the client's browser this seems like a smart idea for the time been, but I am still having seconds thoughts on that.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;One of the major problems is the URL, as medium and Hashnode have different kinds of URLs, some users have subdomains and some user have hosted their blog on their own domain. Writing cases for each kind of URL was a big challenge and I still think it's not fully resolved.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id="heading-future-plans"&gt;Future Plans&lt;/h1&gt;

&lt;p&gt;In the future, there are some features I think are mandatory for this product of mine&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Advance Analytics to keep track of all the blogs across all Platforms.&lt;/li&gt;
&lt;li&gt;A Better markdown editor with Image and gifs and emoji integration support.&lt;/li&gt;
&lt;li&gt;I am thinking to add as many blogging platforms as much as I can.&lt;/li&gt;
&lt;li&gt;Finding a better way to store API keys that is much safer and encrypted.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id="heading-tech-stack"&gt;Tech Stack&lt;/h1&gt;

&lt;p&gt;To build this amazing product I used.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;NEXTJS for frontend and API calls&lt;/li&gt;
&lt;li&gt;Material UI for Design&lt;/li&gt;
&lt;li&gt;Firebase for authentication and Database&lt;/li&gt;
&lt;li&gt;Netlify for Hosting and for scheduling function&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id="heading-links"&gt;Links&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/theashishmaurya/blogtiple"&gt;Github&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.blogtiple.com/"&gt;Live Link&lt;/a&gt; {Hosted On Netlify}&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;This blog is posted using &lt;a href="https://blogtiple.com"&gt;Blogtiple&lt;/a&gt;&lt;/p&gt;

</description>
      <category>netlify</category>
      <category>netlifyhackathon</category>
      <category>blogging</category>
      <category>react</category>
    </item>
    <item>
      <title>Testing Blogtiple</title>
      <dc:creator>Ashish maurya</dc:creator>
      <pubDate>Mon, 28 Feb 2022 20:31:00 +0000</pubDate>
      <link>https://forem.com/theashishmaurya/testing-blogtiple-391k</link>
      <guid>https://forem.com/theashishmaurya/testing-blogtiple-391k</guid>
      <description>&lt;p&gt;This is a test post for Blogtiple.com&lt;/p&gt;


&lt;p&gt;This blog is posted using &lt;a href="https://blogtiple.com"&gt;Blogtiple&lt;/a&gt;&lt;/p&gt;

</description>
      <category>testing</category>
      <category>blogtiple</category>
    </item>
    <item>
      <title>Building our first NFT Marketplace ARCANE without writing single line of Solidity  🖖</title>
      <dc:creator>Ashish maurya</dc:creator>
      <pubDate>Sat, 26 Feb 2022 10:43:41 +0000</pubDate>
      <link>https://forem.com/theashishmaurya/building-our-first-nft-marketplace-arcane-without-writing-single-line-of-solidity-4mkc</link>
      <guid>https://forem.com/theashishmaurya/building-our-first-nft-marketplace-arcane-without-writing-single-line-of-solidity-4mkc</guid>
      <description>&lt;p&gt;Gm folks! It's 2022 😻, the year of getting ourselves in to web3. One morning we notice Hashnode dropped 2022's first hackathon on Web 3.0 with ThirdWeb, isn't it an amazing start for this year? Why wait for any further let's go through what we have cooked for this Hackathon.&lt;/p&gt;

&lt;p&gt;Before that, If you are new to web3 you must be wondering what's Blockchain, NFT, and NFT marketplace? Don't worry I got your back.&lt;/p&gt;

&lt;h3 id="heading-what-is-blockchain"&gt;⛓️ What is Blockchain?&lt;/h3&gt;

&lt;p&gt;Well it's hard to explain Blockchain in a one-liner but let me try&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Blockchain is a public database(ledger)📒 that is updated and shared across many computers(nodes) in a network.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3 id="heading-what-is-nft"&gt;👀 What is NFT?&lt;/h3&gt;

&lt;p&gt;NFT stands for Non-Fungible Token. Wait it doesn't make any sense right? I Know let me explain it when I said Non-fungible that means unique, there is no other of the same kind. 
bitcoin is fungible because when you trade one token for another you got the same, it's different from the previous one.
but when we say non-fungible that means if you trade one token that is totally unique in its way with another non-fungible token you got a different kind.&lt;/p&gt;

&lt;h3 id="heading-what-is-nft-marketplace"&gt;🤔 What is NFT Marketplace?&lt;/h3&gt;

&lt;p&gt;The marketplace is a common platform that acts as a market or meeting point for creators and collectors. Creators come to the marketplace and list their NFTs for sale and collectors buy those listed NFTs.&lt;/p&gt;

&lt;h3 id="heading-problem"&gt;🤷‍♀️Problem&lt;/h3&gt;

&lt;p&gt;In past there was hardly one can verify the provenance of digital contents, like one can verify physical contents in traditional auctions that a given work of art is in fact the original one, not a replica.
As we already know blockchain contains transaction history on a public ledger that is decentralized and can't be altered, which serves the purpose of making any digital content unique in its own way. In laymen's way, we can say tokenization of unique digital content on the blockchain is minting NFT.&lt;/p&gt;

&lt;p&gt;We build a decentralized Marketplace app without writing a single line of solidity code, if you are thinking what's so great about not writing solidity, let me tell you solidity is a strictly typed programming language that is used to write awesome smart contracts. It's a newly developed language specifically writing smart contracts and deploying them on the Ethereum network. Many of us are not very comfortable in writing  👩🏼‍💻smart contract with solidity and understanding all the basic and important components for writing your own smart contract for NFT minting or for another purpose. &lt;/p&gt;

&lt;p&gt;Then what should a person don't want to write contracts but still want to build amazing web3 Dapps 🙇‍♂️. (🥁Drum roll, please !! ) here comes ThirdWeb.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt; 🌐thirdweb&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;ThirdWeb is a portal that provides smart contracts, SDKs, and UI components that creators, developers, etc can integrate into their projects/apps. It's a place where you can get all the web3 related tools and start building your awesome Dapp.&lt;/p&gt;

&lt;p&gt;Using thirdweb SDK, project, and modules we didn't require to pay much attention to the backend part of DApp. We only focus on integration which is totally easy for anyone who is a beginner in frontend development.&lt;/p&gt;

&lt;h3 id="heading-inspiration"&gt;💡Inspiration&lt;/h3&gt;

&lt;p&gt;We got inspired by amazing NFT Marketplaces like &lt;a href="https://opensea.io/"&gt;OpenSea&lt;/a&gt;,&lt;a href="https://rarible.com/"&gt;Rarible&lt;/a&gt;.&lt;/p&gt;

&lt;h3 id="heading-thats-where-arcane-comes-into-the-play"&gt;⚡That's where ARCANE comes into the Play&lt;/h3&gt;

&lt;p&gt;Well, ARCANE is an NFT marketplace where an artist can mint her/his digital content into NFT and store them on the blockchain, letting collectors purchase.
&lt;a href="https://nft-maket-place.vercel.app/"&gt;l&lt;strong&gt;ive demo&lt;/strong&gt;&lt;/a&gt;
We will start with having a crypto wallet. We recommend installing &lt;a href="https://metamask.io/"&gt;Metamask&lt;/a&gt;🦊&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Tv4rptV0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1643658818473/HcMp3H0hZ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Tv4rptV0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1643658818473/HcMp3H0hZ.png" alt="Screenshot 2022-02-01 011935.png" width="880" height="418"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We login into thirdweb via crypto wallet, setting Mumbai as a network for creating projects and modules for our marketplace.
We created NFT, Marketplace module with the current address. after setting up some permission we are ready to use our smart contracts via thirdweb SDK.
Installing thirdweb SDK in Nextjs application.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;&lt;span class="hljs-comment"&gt;//Instantiate 3rdweb SDK&lt;/span&gt;&lt;br&gt;
 const rpcUrl &lt;span class="hljs-operator"&gt;=&lt;/span&gt; &lt;span class="hljs-string"&gt;"&lt;a href="https://rpc-mumbai.maticvigil.com"&gt;https://rpc-mumbai.maticvigil.com&lt;/a&gt;"&lt;/span&gt;;&lt;br&gt;
 const privateKey &lt;span class="hljs-operator"&gt;=&lt;/span&gt; process.env.NEXT_PUBLIC_PRIVATE_KEY;

&lt;p&gt;const wallet &lt;span&gt;=&lt;/span&gt; &lt;span&gt;new&lt;/span&gt; ethers.Wallet(&lt;br&gt;
    privateKey,&lt;br&gt;
    ethers.getDefaultProvider(rpcUrl)&lt;br&gt;
  );&lt;/p&gt;

&lt;p&gt;const market &lt;span&gt;=&lt;/span&gt; &lt;span&gt;new&lt;/span&gt; ThirdwebSDK(wallet).getMarketplaceModule(&lt;br&gt;
    MARKETPLACE_ADDRESS&lt;br&gt;
  );&lt;br&gt;
&lt;/p&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Defining which module to use while minting NFT we needed the NFT module address and for listing and buying needed marketplace module address.&lt;/p&gt;
&lt;br&gt;
&lt;pre&gt;&lt;code&gt;&lt;span class="hljs-comment"&gt;// assign the smart contract address&lt;/span&gt;&lt;br&gt;
const NFT_MODULE_ADDRESS &lt;span class="hljs-operator"&gt;=&lt;/span&gt; &lt;span class="hljs-string"&gt;"0x0C8fe5019D3B3BaC3B9e0878080C898518E02060"&lt;/span&gt;;

&lt;p&gt;&lt;span&gt;// Instantiate NFT Collection module&lt;/span&gt;&lt;br&gt;
 const nft &lt;span&gt;=&lt;/span&gt; &lt;span&gt;new&lt;/span&gt; ThirdwebSDK(wallet).getNFTModule(NFT_MODULE_ADDRESS);&lt;br&gt;
&lt;/p&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;it's now time to mint your digital asset to another address&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7mYOHlS7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1643658944199/EWuINAMlE.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7mYOHlS7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1643658944199/EWuINAMlE.png" alt="Screenshot 2022-02-01 012019.png" width="880" height="424"&gt;&lt;/a&gt;&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;&lt;span class="hljs-comment"&gt;// Minting the NFT asynchronously&lt;/span&gt;

&lt;p&gt;&lt;span&gt;import&lt;/span&gt; { &lt;span&gt;ThirdwebSDK&lt;/span&gt; } &lt;span&gt;&lt;span&gt;from&lt;/span&gt;&lt;/span&gt; &lt;span&gt;"@3rdweb/sdk"&lt;/span&gt;;&lt;br&gt;
&lt;span&gt;import&lt;/span&gt; { &lt;span&gt;ethers&lt;/span&gt; } &lt;span&gt;&lt;span&gt;from&lt;/span&gt;&lt;/span&gt; &lt;span&gt;"ethers"&lt;/span&gt;;&lt;/p&gt;

&lt;p&gt;export default async &lt;span&gt;&lt;span&gt;function&lt;/span&gt; &lt;span&gt;mint&lt;/span&gt;(&lt;span&gt;req, res&lt;/span&gt;) &lt;/span&gt;{&lt;br&gt;
  const rpcUrl &lt;span&gt;=&lt;/span&gt; &lt;span&gt;"&lt;a href="https://rpc-mumbai.maticvigil.com"&gt;https://rpc-mumbai.maticvigil.com&lt;/a&gt;"&lt;/span&gt;;&lt;/p&gt;

&lt;p&gt;const privateKey &lt;span&gt;=&lt;/span&gt; process.env.NEXT_PUBLIC_PRIVATE_KEY;&lt;/p&gt;

&lt;p&gt;const NFT_MODULE_ADDRESS &lt;span&gt;=&lt;/span&gt; &lt;span&gt;"0x0C8fe5019D3B3BaC3B9e0878080C898518E02060"&lt;/span&gt;;&lt;/p&gt;

&lt;p&gt;const { account, name, decription, image } &lt;span&gt;=&lt;/span&gt; await req.body;&lt;br&gt;
  console.log(req.body);&lt;br&gt;
  const wallet &lt;span&gt;=&lt;/span&gt; &lt;span&gt;new&lt;/span&gt; ethers.Wallet(&lt;br&gt;
    privateKey,&lt;br&gt;
    ethers.getDefaultProvider(rpcUrl)&lt;br&gt;
  );&lt;/p&gt;

&lt;p&gt;&lt;span&gt;// initialize the SDK and get the NFT Collection module&lt;/span&gt;&lt;br&gt;
  const nft &lt;span&gt;=&lt;/span&gt; &lt;span&gt;new&lt;/span&gt; ThirdwebSDK(wallet).getNFTModule(NFT_MODULE_ADDRESS);&lt;br&gt;
  await nft&lt;br&gt;
    .mintTo(account, {&lt;br&gt;
      name: name,&lt;br&gt;
      decription: decription,&lt;br&gt;
      image: image,&lt;br&gt;
    })&lt;br&gt;
    .then((metadata) &lt;span&gt;=&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt; {&lt;br&gt;
      console.log(metadata);&lt;br&gt;
      res.&lt;span&gt;send&lt;/span&gt;(JSON.stringify(metadata));&lt;br&gt;
    })&lt;br&gt;
    .catch((e) &lt;span&gt;=&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt; console.log(e));&lt;br&gt;
}&lt;br&gt;
&lt;/p&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;for listing, we need both modules addresses.&lt;/p&gt;
&lt;br&gt;
&lt;pre&gt;&lt;code&gt;&lt;br&gt;
&lt;span class="hljs-comment"&gt;// Declaring the NFT Collection module address&lt;/span&gt;&lt;br&gt;
 const NFT_MODULE_ADDRESS &lt;span class="hljs-operator"&gt;=&lt;/span&gt; &lt;span class="hljs-string"&gt;"0x0C8fe5019D3B3BaC3B9e0878080C898518E02060"&lt;/span&gt;;

&lt;p&gt;&lt;span&gt;// Declaring the MarketPlace  module address&lt;/span&gt;&lt;br&gt;
  const MARKETPLACE_ADDRESS &lt;span&gt;=&lt;/span&gt; &lt;span&gt;"0x229b1f789506dbea2052f8423a780b1be1c16f21"&lt;/span&gt;;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;// Initialize market module by passing in the module address&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;const market &lt;span&gt;=&lt;/span&gt; &lt;span&gt;new&lt;/span&gt; ThirdwebSDK(wallet).getMarketplaceModule(&lt;br&gt;
    MARKETPLACE_ADDRESS&lt;br&gt;
  );&lt;br&gt;
&lt;/p&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;you can list your minted NFT on the marketplace&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZZalHtkq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1643658974126/RcX5CI9xu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZZalHtkq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1643658974126/RcX5CI9xu.png" alt="Screenshot 2022-02-01 011840.png" width="880" height="415"&gt;&lt;/a&gt;&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;&lt;span class="hljs-comment"&gt;// the listingId of the listing you want to fetch data for&lt;/span&gt;&lt;br&gt;
&lt;span class="hljs-keyword"&gt;import&lt;/span&gt; { &lt;span class="hljs-title"&gt;ThirdwebSDK&lt;/span&gt; } &lt;span class="hljs-title"&gt;&lt;span&gt;from&lt;/span&gt;&lt;/span&gt; &lt;span class="hljs-string"&gt;"@3rdweb/sdk"&lt;/span&gt;;&lt;br&gt;
&lt;span class="hljs-keyword"&gt;import&lt;/span&gt; { &lt;span class="hljs-title"&gt;ethers&lt;/span&gt; } &lt;span class="hljs-title"&gt;&lt;span&gt;from&lt;/span&gt;&lt;/span&gt; &lt;span class="hljs-string"&gt;"ethers"&lt;/span&gt;;

&lt;p&gt;export default async &lt;span&gt;&lt;span&gt;function&lt;/span&gt; &lt;span&gt;list&lt;/span&gt;(&lt;span&gt;req, res&lt;/span&gt;) &lt;/span&gt;{&lt;/p&gt;

&lt;p&gt;const rpcUrl &lt;span&gt;=&lt;/span&gt; &lt;span&gt;"&lt;a href="https://rpc-mumbai.maticvigil.com"&gt;https://rpc-mumbai.maticvigil.com&lt;/a&gt;"&lt;/span&gt;;&lt;br&gt;
  const privateKey &lt;span&gt;=&lt;/span&gt; process.env.NEXT_PUBLIC_PRIVATE_KEY;&lt;/p&gt;

&lt;p&gt;const NFT_MODULE_ADDRESS &lt;span&gt;=&lt;/span&gt; &lt;span&gt;"0x0C8fe5019D3B3BaC3B9e0878080C898518E02060"&lt;/span&gt;;&lt;br&gt;
  const MARKETPLACE_ADDRESS &lt;span&gt;=&lt;/span&gt; &lt;span&gt;"0x229b1f789506dbea2052f8423a780b1be1c16f21"&lt;/span&gt;;&lt;br&gt;
 const TOKEN_ADDRESS &lt;span&gt;=&lt;/span&gt; &lt;span&gt;"0x0000000000000000000000000000000000000000"&lt;/span&gt;;  &lt;span&gt;//MATIC Mumbai token address&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;console.log(privateKey);&lt;/p&gt;

&lt;p&gt;const { tokenOffer, tokenId } &lt;span&gt;=&lt;/span&gt; await req.body;&lt;/p&gt;

&lt;p&gt;console.log(req.body);&lt;/p&gt;

&lt;p&gt;const wallet &lt;span&gt;=&lt;/span&gt; &lt;span&gt;new&lt;/span&gt; ethers.Wallet(&lt;br&gt;
    privateKey,&lt;br&gt;
    ethers.getDefaultProvider(rpcUrl)&lt;br&gt;
  );&lt;/p&gt;

&lt;p&gt;const market &lt;span&gt;=&lt;/span&gt; &lt;span&gt;new&lt;/span&gt; ThirdwebSDK(wallet).getMarketplaceModule(&lt;br&gt;
    MARKETPLACE_ADDRESS&lt;br&gt;
  );&lt;/p&gt;

&lt;p&gt;await market&lt;br&gt;
    .createDirectListing({&lt;br&gt;
      assetContractAddress: NFT_MODULE_ADDRESS,&lt;br&gt;
      buyoutPricePerToken: ethers.utils.parseUnits(tokenOffer, &lt;span&gt;18&lt;/span&gt;),&lt;br&gt;
      currencyContractAddress: TOKEN_ADDRESS,&lt;br&gt;
      startTimeInSeconds: Math.floor(Date.now() &lt;span&gt;/&lt;/span&gt; &lt;span&gt;1000&lt;/span&gt;),&lt;br&gt;
      listingDurationInSeconds: &lt;span&gt;60&lt;/span&gt; &lt;span&gt;&lt;em&gt;&lt;/em&gt;&lt;/span&gt; &lt;span&gt;60&lt;/span&gt; &lt;span&gt;&lt;/span&gt; &lt;span&gt;24&lt;/span&gt;,&lt;br&gt;
      tokenId: tokenId,&lt;br&gt;
      quantity: &lt;span&gt;1&lt;/span&gt;,&lt;br&gt;
    })&lt;br&gt;
    .then((data) &lt;span&gt;=&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt; {&lt;br&gt;
      console.log(data);&lt;br&gt;
      res.&lt;span&gt;send&lt;/span&gt;(JSON.stringify(data));&lt;br&gt;
    })&lt;br&gt;
    .catch((&lt;span&gt;&lt;span&gt;error&lt;/span&gt;) =&amp;gt; &lt;/span&gt;{&lt;br&gt;
      console.log(&lt;span&gt;&lt;span&gt;error&lt;/span&gt;)&lt;/span&gt;;&lt;br&gt;
    });&lt;br&gt;
}&lt;br&gt;
&lt;/p&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;🥳Woohooo!! we have minted our digital assets and listed them on the Polygon blockchain without writing any line of solidity smart contract way to go thirdweb  ✨.&lt;/p&gt;

&lt;p&gt;Now it's time to reveal the tech-stack we have used to build this amazing marketplace  🙈&lt;/p&gt;

&lt;h3 id="heading-techstack-used"&gt;📚 TechStack Used&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Framework and Services&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://nextjs.org/"&gt;NextJS&lt;/a&gt; - for Frontend&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://mui.com/getting-started/installation/"&gt;Material UI&lt;/a&gt; - for styling the website&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://thirdweb.com/"&gt;thirdweb&lt;/a&gt; - for getting pre-build smart contracts&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Libraries&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://docs.ethers.io/v5/"&gt;ether.js&lt;/a&gt;- for interacting with the Ethereum Blockchain and its ecosystem&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.npmjs.com/package/axios"&gt;axios&lt;/a&gt; - Promise based HTTP client for the browser and node.js&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.ipfs.io/reference/js/api/"&gt;ipfs-http-client&lt;/a&gt;  - The JavaScript HTTP RPC API client library for IPFS implementations.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id="heading-team-and-collaborator"&gt;👯‍♂️ Team and Collaborator&lt;/h3&gt;

&lt;p&gt;I have been in collaboration with &lt;a href="https://hashnode.com/@SnehaMaurya"&gt;Sneha Maurya&lt;/a&gt; who handles backend, API/SDK integrations, and web3 related functionalities✌️.&lt;/p&gt;

&lt;h3 id="heading-deploying"&gt;🚀 Deploying&lt;/h3&gt;

&lt;p&gt;The whole app is deployed on &lt;a href="https://nft-maket-place.vercel.app/"&gt;Vercel&lt;/a&gt;,  🏃🏽‍♀️ go and check it out.&lt;/p&gt;

&lt;h3 id="heading-links-and-resources"&gt;🌐 Links and resources&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Live demo - &lt;a href="https://nft-maket-place.vercel.app/"&gt;ARCANE&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Github Repository link -&lt;a href="https://github.com/theashishmaurya/nftMaketPlace"&gt;Github-NFTMarketplace&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;connect to us on twitter - @sneha_kushw and &lt;a class="mentioned-user" href="https://dev.to/theashishmaurya"&gt;@theashishmaurya&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id="heading-future-possibilities"&gt;🤖 Future Possibilities&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;buying listed NFT using our custom/existing currency token form marketplace&lt;/li&gt;
&lt;li&gt;adding royalties for minted NFTs.&lt;/li&gt;
&lt;li&gt;adding more crypto wallets for accessing our website.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;This blog is posted using &lt;a href="https://blogtiple.com"&gt;Blogtiple&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>thirdweb</category>
      <category>thirdwebhackathon</category>
      <category>web3</category>
    </item>
    <item>
      <title>FIREBASE &amp; REACT: Setting Up React APP with Firebase</title>
      <dc:creator>Ashish maurya</dc:creator>
      <pubDate>Thu, 24 Feb 2022 17:48:59 +0000</pubDate>
      <link>https://forem.com/theashishmaurya/firebase-react-setting-up-react-app-with-firebase-2gba</link>
      <guid>https://forem.com/theashishmaurya/firebase-react-setting-up-react-app-with-firebase-2gba</guid>
      <description>&lt;p&gt;In this article, we will learn how to create a new Reactjs app and integrate Firebase in our React application.&lt;/p&gt;

&lt;h1 id="1-what-is-firebase"&gt;1. What is Firebase&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;Firebase is Google’s mobile application development platform that helps you build, improve, and grow your app.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Firebase is a toolset to “build, improve, and grow your app”, and the tools it gives you cover a large portion of the services that developers would normally have to build themselves, but don’t really want to build, because they’d rather be focusing on the app experience itself. This includes things like analytics, authentication, databases, configuration, file storage, push messaging, and the list goes on. The services are hosted in the cloud and scale with little to no effort on the part of the developer.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--36H4D2Ki--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1632393207997/g8sRSLz_U.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--36H4D2Ki--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1632393207997/g8sRSLz_U.png" alt="image.png" width="700" height="438"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;now that we have a little gist of Firebase let's set up our application now.&lt;/p&gt;

&lt;h1 id="2-setting-up-react-application"&gt;2. Setting Up React application.&lt;/h1&gt;

&lt;p&gt;In this tutorial, we will be using Create-react-app. If you are new to React, here is an article about how to set up the React Application in your local.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://blog.theashishmaurya.me/setting-up-react-app-and-writing-your-first-hello-world"&gt;&lt;/a&gt;&lt;a href="https://blog.theashishmaurya.me/setting-up-react-app-and-writing-your-first-hello-world"&gt;https://blog.theashishmaurya.me/setting-up-react-app-and-writing-your-first-hello-world&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;once you have followed the above article for setting up the React-App we will now move to our next part where we set up the Firebase for our application.&lt;/p&gt;

&lt;h1 id="3-setting-up-the-firebase-for-web-application"&gt;3. Setting up the firebase for Web Application&lt;/h1&gt;

&lt;p&gt;Once the above process is done now let's set up the Firebase for our App.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Go to &lt;a href="https://firebase.google.com"&gt;Firebase.google.com&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UlU6M1A1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1632392584335/0Rfvd4i2z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UlU6M1A1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1632392584335/0Rfvd4i2z.png" alt="image.png" width="880" height="428"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click on get started and add a project to it.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Once done give it any name and then just create the project. Once the project is created you will be getting something like the below.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--upfnnTqE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1632394156447/oQ_FD2a7w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--upfnnTqE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1632394156447/oQ_FD2a7w.png" alt="image.png" width="632" height="352"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click on the &lt;code&gt;&amp;lt;/&amp;gt;&lt;/code&gt; icon that will initiate a web app in the firebase.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Name whatever name you wanna give to your web app once done, Save it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---dtCrqni--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1632394458972/esCH4y8CCT.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---dtCrqni--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1632394458972/esCH4y8CCT.png" alt="image.png" width="880" height="415"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;After that, you will be given your config keys for the web app make sure to not expose the keys. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3R2o1O8n--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1632394765339/0vauZI4vV.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3R2o1O8n--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1632394765339/0vauZI4vV.png" alt="image.png" width="880" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;once done you are done with the firebase console setting let's install the firebase package in our local.&lt;/p&gt;

&lt;h1 id="4-setting-up-firebase-with-react-application"&gt;4. Setting up Firebase with React Application.&lt;/h1&gt;

&lt;p&gt;Now we are done with the firebase side now all we need to set up everything in our local Application.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open the terminal and install the firebase package.&lt;/li&gt;
&lt;/ul&gt;


&lt;pre&gt;&lt;code&gt;&lt;span class="hljs-built_in"&gt;npm&lt;/span&gt; install firebase&lt;br&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;

&lt;li&gt;Once Installed,open the React app folder and add a new file `.env.local to it.&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QN8M7Pvx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1632395178384/w-m8caPrg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QN8M7Pvx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1632395178384/w-m8caPrg.png" alt="image.png" width="200" height="372"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Now we will configure the &lt;code&gt;.env.local&lt;/code&gt; file, where we put all our environment variables.&lt;/li&gt;
&lt;/ul&gt;


&lt;pre&gt;&lt;code&gt;&lt;span class="hljs-attr"&gt;REACT_APP_FIREBASE_API_KEY&lt;/span&gt; = &lt;span class="hljs-string"&gt;"YOUR-UNIQUE-CREDENTIALS"&lt;/span&gt;&lt;br&gt;
&lt;span class="hljs-attr"&gt;REACT_APP_FIREBASE_AUTH_DOMAIN&lt;/span&gt; = &lt;span class="hljs-string"&gt;"YOUR-PROJECT-NAME.firebaseapp.com"&lt;/span&gt;&lt;br&gt;
&lt;span class="hljs-attr"&gt;REACT_APP_FIREBASE_PROJECT_ID&lt;/span&gt; = &lt;span class="hljs-string"&gt;"YOUR-PROJECT-FIREBASE-PROJECT-ID"&lt;/span&gt;&lt;br&gt;
&lt;span class="hljs-attr"&gt;REACT_APP_FIREBASE_STORAGE_BUCKET&lt;/span&gt; = &lt;span class="hljs-string"&gt;"YOUR-PROJECT-NAME.appspot.com"&lt;/span&gt;&lt;br&gt;
&lt;span class="hljs-attr"&gt;REACT_APP_FIREBASE_MESSAGING_SENDER_ID&lt;/span&gt; = &lt;span class="hljs-string"&gt;"YOUR-PROJECT-SENDER-ID"&lt;/span&gt;&lt;br&gt;
&lt;span class="hljs-attr"&gt;REACT_APP_FIREBASE_APP_ID&lt;/span&gt; = &lt;span class="hljs-string"&gt;"YOUR-PROJECT-APP-ID"&lt;/span&gt;&lt;br&gt;
&lt;span class="hljs-attr"&gt;REACT_APP_MEASUREMENT_ID&lt;/span&gt; = &lt;span class="hljs-string"&gt;"YOUR-MEASUREMENT-ID"&lt;/span&gt;&lt;br&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Save the file and restart the server. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;After saving the &lt;code&gt;.evn.local&lt;/code&gt; file we need to initiate the firebase in our application
for that, we will create a new folder name &lt;code&gt;firebase&lt;/code&gt; and then also create a new file and name it &lt;code&gt;firebase.js&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YOSlnqT7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1632395913535/AmEgQwpBK.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YOSlnqT7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1632395913535/AmEgQwpBK.png" alt="image.png" width="195" height="321"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Once done copy the following code inside the file.&lt;/li&gt;
&lt;/ul&gt;


&lt;pre&gt;&lt;code&gt;&lt;span class="hljs-keyword"&gt;import&lt;/span&gt; { initializeApp } &lt;span class="hljs-keyword"&gt;from&lt;/span&gt; &lt;span class="hljs-string"&gt;"firebase/app"&lt;/span&gt;;

&lt;p&gt;&lt;span&gt;// &lt;span&gt;TODO:&lt;/span&gt; Add SDKs for Firebase products that you want to use&lt;/span&gt;&lt;br&gt;
&lt;span&gt;// &lt;a href="https://firebase.google.com/docs/web/setup#available-libraries"&gt;https://firebase.google.com/docs/web/setup#available-libraries&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;// Your web app's Firebase configuration&lt;/span&gt;&lt;br&gt;
&lt;span&gt;// For Firebase JS SDK v7.20.0 and later, measurementId is optional&lt;/span&gt;&lt;br&gt;
&lt;span&gt;const&lt;/span&gt; clientCredentials = {&lt;br&gt;
  &lt;span&gt;apiKey&lt;/span&gt;: process.env.REACT_APP_FIREBASE_API_KEY,&lt;br&gt;
  &lt;span&gt;authDomain&lt;/span&gt;: process.env.REACT_APP_FIREBASE_AUTH_DOMAIN,&lt;br&gt;
  &lt;span&gt;projectId&lt;/span&gt;: process.env.REACT_APP_FIREBASE_PROJECT_ID,&lt;br&gt;
  &lt;span&gt;storageBucket&lt;/span&gt;: process.env.REACT_APP_FIREBASE_STORAGE_BUCKET,&lt;br&gt;
  &lt;span&gt;messagingSenderId&lt;/span&gt;: process.env.REACT_APP_FIREBASE_MESSAGING_SENDER_ID,&lt;br&gt;
  &lt;span&gt;appId&lt;/span&gt;: process.env.REACT_APP_FIREBASE_APP_ID,&lt;br&gt;
  &lt;span&gt;measurementId&lt;/span&gt;: process.env.REACT_APP_MEASUREMENT_ID,&lt;br&gt;
};&lt;/p&gt;

&lt;p&gt;&lt;span&gt;// Initialize Firebase&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;export&lt;/span&gt; &lt;span&gt;const&lt;/span&gt; app = initializeApp(clientCredentials);&lt;/p&gt;

&lt;p&gt;&lt;span&gt;//&lt;/span&gt;&lt;br&gt;
&lt;/p&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;

&lt;li&gt;Now you are all set, firebase has been initiated in your app now you can use different firebase services in your app.&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;All you need is to import them from firebase.&lt;/p&gt;

&lt;h1 id="summary"&gt;Summary&lt;/h1&gt;

&lt;p&gt;we learned to create a new React application using create-react-app and also how to initiate firebase in our React application. We also learned how not to expose the firebase environment keys by using &lt;code&gt;.evn&lt;/code&gt; files.&lt;/p&gt;

&lt;p&gt;In the next article, we will learn about creating an Authentication application using firebase auth and react's popular framework NEXTJS.&lt;/p&gt;

&lt;p&gt;If you liked my work considering the following and liking this article, it keeps me motivated and in case you want to connect to me feel free to email me at ashish.1999vns@gmail.com or connecting me on Twitter.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://twitter.com/theysaymaurya/status/1438924150588915716?s=20"&gt;&lt;/a&gt;&lt;a href="https://twitter.com/theysaymaurya/status/1438924150588915716?s=20"&gt;https://twitter.com/theysaymaurya/status/1438924150588915716?s=20&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;also if you wanna support me please consider buying me coffee.&lt;/p&gt;


&lt;p&gt;This blog is posted using &lt;a href="https://blogtiple.com"&gt;Blogtiple&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>firebase</category>
      <category>serverless</category>
      <category>authentication</category>
    </item>
    <item>
      <title>Everything You Should Know About Blockchain.</title>
      <dc:creator>Ashish maurya</dc:creator>
      <pubDate>Thu, 24 Feb 2022 16:51:35 +0000</pubDate>
      <link>https://forem.com/theashishmaurya/everything-you-should-know-about-blockchain-ggp</link>
      <guid>https://forem.com/theashishmaurya/everything-you-should-know-about-blockchain-ggp</guid>
      <description>&lt;p&gt;A lot has changed since blockchain first arrived in the 1990s and since then it's changing our world in a way no one has predicted. If you have been active on the internet you must have heard people throwing words like NFT, Ethereum or you must have heard about some famous crypto coin like Dogecoin or Bitcoin.&lt;/p&gt;

&lt;p&gt;Here is a tweet of Elon musk about Dogecoin.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://twitter.com/elonmusk/status/1284291528328790016"&gt;&lt;/a&gt;&lt;a href="https://twitter.com/elonmusk/status/1284291528328790016"&gt;https://twitter.com/elonmusk/status/1284291528328790016&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is a tweet about Jack Dorsey which was sold for  NFT for over $2.9 million&lt;/p&gt;

&lt;p&gt;&lt;a href="https://twitter.com/jack/status/20?lang=en"&gt;&lt;/a&gt;&lt;a href="https://twitter.com/jack/status/20?lang=en"&gt;https://twitter.com/jack/status/20?lang=en&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you wanna know more about NFT read an &lt;a href="https://likam5.hashnode.dev/non-fungible-tokens-nfts"&gt;article&lt;/a&gt; by &lt;a href="https://hashnode.com/@Like-iam5"&gt;Like I'm 5&lt;/a&gt; on NFT.&lt;/p&gt;

&lt;p&gt;All the famous cryptocurrencies like BTC, Ethereum, or any other coin like Ethereum classic or Bitcoin cash run on Blockchain and something to know NFT which works on Ethereum which runs on Blockchain.&lt;/p&gt;

&lt;p&gt;So the question arises what is this BLOCKCHAIN everything is running on.&lt;/p&gt;

&lt;p&gt;let's see&lt;/p&gt;

&lt;h1 id="genesis-of-the-blockchain"&gt;Genesis of The Blockchain&lt;/h1&gt;

&lt;p&gt;Well, the blockchain is originated way before any cryptocurrencies emerged or hypothetically saying, even theorized. A cryptographer named David Chaum first tossed the idea of the blockchain-like protocol in his 1982 dissertation &lt;strong&gt;" Computer Systems Established, Maintained, and Trusted by Mutually Suspicious Groups ".&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Further work on a cryptographically secured chain of blocks was described in 1991 by Stuart Haber and W. Scott Stornetta. They wanted to implement a system wherein document timestamps could not be tampered with.&lt;/p&gt;

&lt;p&gt;It wasn't till 2008 when the first blockchain was conceptualized by a group/people know as &lt;strong&gt;Satoshi Nakamoto&lt;/strong&gt;. Nakamoto improved the design in an important way using a Hashcash-like method to timestamp blocks without requiring them to be signed by a trusted party and introducing a difficulty parameter to stabilize the rate with which blocks are added to the chain. The design was implemented the following year by Nakamoto as a core component of the cryptocurrency bitcoin, where it serves as the public ledger for all transactions on the network.&lt;/p&gt;

&lt;h1 id="how-blockchain-works"&gt;How Blockchain works&lt;/h1&gt;

&lt;p&gt;As the name suggests blockchains are nothing but a big chain of interconnected blocks. Where every block contains their previous block's hash value and that is how they are linked as well as their own unique hash.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--s0JlT6_e--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1631349870665/SeVPXHqCG.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--s0JlT6_e--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1631349870665/SeVPXHqCG.png" alt="Blockchain blocks" width="880" height="451"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now that we have a gist of what blockchain is let's dive deeper into the technicality of Blockchains.&lt;/p&gt;

&lt;h2 id="why-blockchain"&gt;Why Blockchain?&lt;/h2&gt;

&lt;p&gt;Blockchains are decentralized and transparent which means anyone can add their own block on the blockchain given that they have to do certain work to add it. This process is called mining and it is well rewarded. We will talk more about mining later in this article.&lt;/p&gt;

&lt;p&gt; It is well secured by powerful cryptography which makes it impossible to tamper with. Also, blockchain is publicly broadcasted and are decentralized which makes it immutable and impossible to temper.&lt;/p&gt;

&lt;h3 id="but-what-is-decentralization"&gt;But what is Decentralization?&lt;/h3&gt;

&lt;p&gt;To understand this concept of decentralization let's first understand how banks and transactions work right now.&lt;/p&gt;

&lt;p&gt;Suppose you want to share money with your friend Bob who is miles away from you. So what will you do is open your Application on your mobile and transfer the money to Bob's account. &lt;/p&gt;

&lt;p&gt;So what is happening behind the scene is you are not sending money to Bob instead you are sending a message to the bank. &lt;code&gt;A message you kidding me?&lt;/code&gt; Well, if you think a little more money is nothing but some number in this digital world. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fmYc4a8m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1631352245692/CrHcfCNk_.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fmYc4a8m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1631352245692/CrHcfCNk_.png" alt="image.png" width="582" height="328"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So our message might look something like this.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt; { &lt;br&gt;
    &lt;span class="hljs-attr"&gt;"To"&lt;/span&gt; : &lt;span class="hljs-string"&gt;"BOB"&lt;/span&gt;,&lt;br&gt;
    &lt;span class="hljs-attr"&gt;"From"&lt;/span&gt; : &lt;span class="hljs-string"&gt;"Alice"&lt;/span&gt;,&lt;br&gt;
    &lt;span class="hljs-attr"&gt;"Ammount"&lt;/span&gt; : &lt;span class="hljs-string"&gt;"500 $"&lt;/span&gt;&lt;br&gt;
}&lt;br&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So in this message, we are saying send 500$ to Bob. After the bank receives this message from your device it will check so certain tasks to complete the transaction.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;It will open the ledger ( A ledger balance is computed by a bank at the end of each business day and includes all withdrawals and deposits to calculate the total amount of money in a bank account.) and check if Alice has enough money to transfer i.e if Alice has 500$ or more.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If the above condition is met then the ledger is updated where the new balance of Alice will be the old balance - 500 $ and a new balance of the Bob will be the old balance + 500$.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;After this both receive a message that their transaction is successful. &lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So this was how the transaction works with banks. But the problem with it is you can never verify the transaction yourself or you can never see what is happening inside the book of the bank you trust they can manage your money and all the power is centralized around the bank. They have the power to create new money (as I already said it's just a number) or transfer if they want. &lt;/p&gt;

&lt;p&gt;This centralization of power is something from which the community is not happy with and blockchain solves the problem using a decentralized method of adding a transaction.&lt;/p&gt;

&lt;p&gt;Now let's understand how Blockchain handles this kind of transaction between Alice and Bob.&lt;/p&gt;

&lt;p&gt;Now Alice wants to send some money to Bob through Blockchain. This transaction will happen without the interference of any central power.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--N-7HrO6N--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1631372540075/miwoMBpBL.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--N-7HrO6N--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1631372540075/miwoMBpBL.png" alt="image.png" width="880" height="495"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So what's really happening is shown in the below image.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zOd_Uqxj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1631372425979/NElsU3SXi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zOd_Uqxj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1631372425979/NElsU3SXi.png" alt="Transaction In blockchain" width="830" height="559"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When a transaction is made it creates a block that block is then sent to every node where miners compete with one another to add that block to the main block. On successfully doing that each miner is paid in cryptocurrencies, but that is the miner's logic which can be discussed in the next article. &lt;/p&gt;

&lt;p&gt;For now, we understood how decentralization happens in the blockchain.&lt;/p&gt;

&lt;p&gt; So now you might though if no one is governing the transactions then how is it getting validating and adding to blockchain who is doing all that work? Here come's the miners who validate the transaction and add it to the block.&lt;/p&gt;

&lt;h1 id="who-are-miners-and-how-mining-logic-works"&gt;Who are Miners and how Mining Logic Works&lt;/h1&gt;

&lt;p&gt;Well, till now it's clear that the blockchain is made of a number of blocks. So what are these blocks and which kind of data do they contain.&lt;/p&gt;

&lt;p&gt;Well if we see an overview block looks something like below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--098i2vCy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1631476105347/a9mYl_Xyp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--098i2vCy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1631476105347/a9mYl_Xyp.png" alt="Merkel Tree Example" width="880" height="407"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this, we can see that a single block contain &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Previous Hash&lt;/li&gt;
&lt;li&gt;Nonce &lt;/li&gt;
&lt;li&gt;TimeStamp&lt;/li&gt;
&lt;li&gt;Merkel Root.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But in exact a block look something like this with a lot of data&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Nps3Rv_K--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1631476237071/CgxoVytuQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Nps3Rv_K--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1631476237071/CgxoVytuQ.png" alt="image.png" width="880" height="491"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can see all the transactions and blocks of the public Blockchain. Here I used &lt;a href="https://etherscan.io"&gt;Etherscan&lt;/a&gt; to get the block data but there are a lot of services out there.&lt;/p&gt;

&lt;p&gt;So what happens is every time transactions are made they came to miners where miners validate the transactions and then try to add that block to the public Blockchain.&lt;/p&gt;

&lt;p&gt;Why I used "try to add"? Instead of add, well every miner is trying to add a new block to the Blockchain continuously all the time and it's like a race between every miner.&lt;/p&gt;

&lt;p&gt;The way blockchain validates a block is valid or not is called &lt;strong&gt;Consensus Mechanism&lt;/strong&gt;. There are different ways the Consensus Mechanism works one which is very popular is &lt;strong&gt;Proof of Work&lt;/strong&gt; others are &lt;em&gt;Proof of stake&lt;strong&gt;, &lt;/strong&gt;Proof of Capacity&lt;strong&gt;, &lt;/strong&gt;Proof of Activity*&lt;/em&gt; .&lt;/p&gt;

&lt;p&gt;In this article, we will only talk about the Proof of Work.&lt;/p&gt;

&lt;p&gt;In Proof of Work, every miner has to compute a hash value for the block in some given condition.&lt;/p&gt;

&lt;p&gt;Let say you are a miner and you have to calculate a hash value that should start with 4 0's&lt;/p&gt;

&lt;p&gt;for example : 0000x147a9393258780beef7d&lt;/p&gt;

&lt;p&gt;to calculate something like this take a lot of trial and error and a lot of computational power. And also there is only one thing you can change in the block which is the value of  Nonce.&lt;/p&gt;

&lt;p&gt;So for every time you want a new hash value, you keep incrementing the value of Nonce and by finding a valid hash you can add that hash to the block.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--B8fVoxv4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1631477900650/hKVQCLFlS.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--B8fVoxv4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1631477900650/hKVQCLFlS.png" alt="image.png" width="880" height="490"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Well if any miner can add to the Blockchain isn't that make the Blockchain untrustable and unsafe. &lt;/p&gt;

&lt;p&gt;Well here comes the power of Decentralization to save you. Every time a miner adds a block to the Blockchain other miners do a validation check on that block. If the block is valid and matches with their own version of Blockchain if everything is valid they add that Blockchain to their own version of Blockchain and start mining the new block.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6gSSYDnn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1631566844776/tTs4pHjlt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6gSSYDnn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1631566844776/tTs4pHjlt.png" alt="Blockchain.png" width="880" height="490"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Say, if some malicious group tries to add an invalid block to the Blockchain for their own profile. After successfully mining the Blockchain their block will be rejected by other miners which can cost them a lot of money and computation power.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--x5Xv56E---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1631567043591/1_jWHNeQi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--x5Xv56E---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1631567043591/1_jWHNeQi.png" alt="Blockchain.png" width="880" height="489"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If another miner successfully mines a valid block the whole Blockchain will move to that version of the block and malicious manner have to sync up to mine the next block.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fFodoNnM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1631569630595/hPLQ5gYat.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fFodoNnM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1631569630595/hPLQ5gYat.png" alt="image.png" width="880" height="491"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Well, for every success full mining each miner is given some reward. For mining on BTC Blockchain, it's BTC coin and on mining on ethereum Blockchain, it's ethereum.&lt;/p&gt;

&lt;p&gt;fun fact: It's the only time a new coin is created. (It's just an analogy)&lt;/p&gt;

&lt;p&gt;well till now we learned about what is Blockchain and now a new block is created and added. &lt;/p&gt;

&lt;p&gt;But, we have no clue about how transactions take place in the blockchain.&lt;/p&gt;

&lt;h2 id="how-the-transaction-works-in-blockchain"&gt;How the transaction works in Blockchain.&lt;/h2&gt;

&lt;p&gt;Let's again take Alice and Bob's example and understand the transaction in-depth and how every transaction is protected.&lt;/p&gt;

&lt;p&gt;But before that let us look at the concept of asymmetric encryption.&lt;/p&gt;

&lt;h3 id="asymmetric-encryption-and-how-it-works-in-blockchain"&gt;Asymmetric encryption and how it works in Blockchain.&lt;/h3&gt;

&lt;p&gt;Now, to understand this let's first understand how symmetric encryption works. Suppose Bob wants to send some data to Alice but the data is sensitive and Bob wants to send this in a way that only Alice can read it. Alice will send her on the box so that Bob can put the data in a box and close it. Once the box is closed only Alice can open the Box with her key, let's call this key Alice's Private key.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yDtMMGU---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1631566793316/h4NIVWufK.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yDtMMGU---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1631566793316/h4NIVWufK.png" alt="image.png" width="880" height="493"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now in cryptography same concept is happen, to send a message to Alice Bob encrypts the data using the Hash function such that only Alice's private key can Hash it back to the original data.&lt;/p&gt;

&lt;p&gt;The problem with the above method was for every time Alice wants to receive a message Alice have to create numerous keys and boxes to receive messages from numerous people. This can be really problematic and hence the concept of the Asymmetric key was introduced.&lt;/p&gt;

&lt;p&gt;Now in the Asymmetric Encryption key, Alice has two keys one is called Alice's private key and the other is called Alice's Public key. Now the public key is shareable and the private key must not be disclosed.&lt;/p&gt;

&lt;p&gt;Now, every time someone wants to send a message to Alice they can use Alice's public key and send it to Alice now that message can only be decrypted by Alice's private key.&lt;/p&gt;

&lt;p&gt;The math behind is quite long so we will discuss it in later articles, but for now, we understood the private and public key concept. Let's see how it is implied in Blockchain&lt;/p&gt;

&lt;p&gt;In Blockchain when Alice wants to send money to BOB that data will be sent to the miner where they verify some conditions like the following.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Does Alice have enough money?&lt;/li&gt;
&lt;li&gt;Does Alice is the one who sent the money to Bob or is it someone else.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For checking the available balance in the wallet BTC uses something called UTXO. An overview on UTXO will be that it is a set of all the previous transaction is done by Alice and after adding and subtracting everything if the balance matches then miner approve the transaction.&lt;/p&gt;

&lt;p&gt;And to verify if the transaction Is came from Alice something called a Digital signature is used where Alice signs with her private key and sends it to the miner with other data. Well, you have to understand that those logics are automatically implemented in the wallet and Alice doesn't actually sign anything. Moving on what kind of data is sent to the miner?&lt;/p&gt;

&lt;p&gt;Well, the data might look something like this with other data of course&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cr1tXyWa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1631569095992/rFrz7FzKr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cr1tXyWa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1631569095992/rFrz7FzKr.png" alt="Blockchain Transaction" width="880" height="487"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once it is received the miner will validate the transaction and add it to the Blockchain. Once added to Blockchain the data becomes immutable.&lt;/p&gt;

&lt;h2 id="summary"&gt;Summary&lt;/h2&gt;

&lt;p&gt;Today we learned about how Blockchain works and how data/transactions are added to the Blockchain. Once the transaction came to the miner, the miner validates the data and calculates a valid nonce value to add his version of the block to the Blockchain. Once added the miner get a reward but if the miner tries to add malicious data then it gets declined by rest of the miner and once more than 50% miners agree to some nonce then that will become the main branch and malicious data will not be added to the main branch of the blockchain.&lt;/p&gt;

&lt;p&gt;So, this was an overview of Blockchain technology I hope you liked the article. I will be posting more in-depth knowledge about this topic from time to time. To get notified please subscribe to my newsletter.&lt;/p&gt;

&lt;p&gt;References:-&lt;/p&gt;

&lt;p&gt;https://en.wikipedia.org/wiki/Blockchain#History &lt;/p&gt;

&lt;p&gt;https://blog.ethereum.org/2015/11/15/merkling-in-ethereum/&lt;/p&gt;

&lt;p&gt;https://etherscan.io&lt;/p&gt;


&lt;p&gt;This blog is posted using &lt;a href="www.blogtiple.com"&gt;Blogtiple&lt;/a&gt;&lt;/p&gt;

</description>
      <category>2articles1week</category>
      <category>blockchain</category>
      <category>encryption</category>
      <category>cryptocurrency</category>
    </item>
    <item>
      <title>Do You Really Know UseEffect?</title>
      <dc:creator>Ashish maurya</dc:creator>
      <pubDate>Thu, 24 Feb 2022 09:25:09 +0000</pubDate>
      <link>https://forem.com/theashishmaurya/do-you-really-know-useeffect-19g3</link>
      <guid>https://forem.com/theashishmaurya/do-you-really-know-useeffect-19g3</guid>
      <description>&lt;p&gt;React 16.8 comes bearing with gifts such as Hooks and React community couldn't be happier and why won't they be as Hooks gives the developer to create functional components with the power of Class components.&lt;/p&gt;

&lt;h2 id="some-of-the-famous-hooks-are"&gt;Some of the famous hooks are&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;State Hook &lt;/li&gt;
&lt;li&gt;Effect Hook&lt;/li&gt;
&lt;li&gt;Context Hook and so on.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But do you really understand them? Let's talk about the &lt;code&gt;Effect Hook&lt;/code&gt; in this article and we will try to understand when and how to use them.&lt;/p&gt;

&lt;h2 id="using-effect-hooks"&gt;Using Effect Hooks&lt;/h2&gt;

&lt;p&gt;As mentioned in the document &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The Effect Hook lets you perform side effects in function components&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;let's talk about what are these side effects? Imagine you are making a web app where you are needed to &lt;code&gt;fetch&lt;/code&gt; some data from the server or set up a subscription using &lt;code&gt;WebRTC&lt;/code&gt; these are some examples of side effects.&lt;/p&gt;

&lt;p&gt;In the above example where you are fetching some data from API does not need cleanup means you can execute the function and forget about it. But the later one where you are subscribing needs the cleanup where you have to write some addition line so that every time your component unmounts the cleanup happens and your resources are not wasted up.&lt;/p&gt;

&lt;h3 id="lets-talk-about-the-effects-without-cleanup"&gt;let's talk about the Effects without Cleanup&lt;/h3&gt;

&lt;p&gt;For using Effects in our React functional component we use &lt;code&gt;useEffect&lt;/code&gt; Hook&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;  useEffect (&lt;span class="hljs-function"&gt;&lt;span&gt;()&lt;/span&gt;=&amp;gt;&lt;/span&gt;{&lt;br&gt;
     &lt;span class="hljs-built_in"&gt;console&lt;/span&gt;.log(&lt;span class="hljs-string"&gt;"Something Happened"&lt;/span&gt;)&lt;br&gt;
   })&lt;br&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now &lt;code&gt;useEffect&lt;/code&gt; accepts two arguments one is a callback function and one is an array.&lt;/p&gt;

&lt;h3 id="case-1"&gt;Case 1&lt;/h3&gt;

&lt;p&gt;In this, we won't pass the second argument, and let's see what happens.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;useEffect (&lt;span class="hljs-function"&gt;&lt;span&gt;()&lt;/span&gt;=&amp;gt;&lt;/span&gt;{&lt;br&gt;
     &lt;span class="hljs-built_in"&gt;console&lt;/span&gt;.log(&lt;span class="hljs-string"&gt;"Something Changed"&lt;/span&gt;)&lt;br&gt;
   })&lt;br&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Result:&lt;/strong&gt; Every time our components render the &lt;code&gt;useEffect&lt;/code&gt; Hook gonna run and we can see the text &lt;code&gt;Something Changed&lt;/code&gt; in the console.&lt;/p&gt;

&lt;h3 id="case-2"&gt;Case 2&lt;/h3&gt;

&lt;p&gt;In this, we will pass an empty array as the second argument &lt;code&gt;[ ]&lt;/code&gt;, and let's see what happens.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;useEffect (&lt;span class="hljs-function"&gt;&lt;span&gt;()&lt;/span&gt;=&amp;gt;&lt;/span&gt;{&lt;br&gt;
     &lt;span class="hljs-built_in"&gt;console&lt;/span&gt;.log(&lt;span class="hljs-string"&gt;"Only Once"&lt;/span&gt;)&lt;br&gt;
   },[ ])&lt;br&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Result:&lt;/strong&gt; This time &lt;code&gt;useEffect&lt;/code&gt; Hook gonna run on mounting/ unmounting of our component and we can see the text &lt;code&gt;Only Once&lt;/code&gt; in the console for only one time.&lt;/p&gt;

&lt;h3 id="case-3"&gt;Case 3&lt;/h3&gt;

&lt;p&gt;In this, we will pass an array containing a state value as the second argument &lt;code&gt;[ someState]&lt;/code&gt;, and let's see what happens. &lt;/p&gt;


&lt;pre&gt;&lt;code&gt; const [someState , setSomeState] = useState();

&lt;p&gt;useEffect (&lt;span&gt;&lt;span&gt;()&lt;/span&gt;=&amp;gt;&lt;/span&gt;{&lt;br&gt;
     &lt;span&gt;console&lt;/span&gt;.log(&lt;span&gt;"State Changed"&lt;/span&gt;)&lt;br&gt;
   },[someState ]);&lt;br&gt;
&lt;/p&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Result:&lt;/strong&gt; This time &lt;code&gt;useEffect&lt;/code&gt; Hook gonna run when the value of the &lt;code&gt;someState&lt;/code&gt; changes of our component and we can see the text &lt;code&gt;State Changed&lt;/code&gt; in the console when we change the state.&lt;/p&gt;

&lt;h2 id="enough-theory-lets-see-some-code-now"&gt;Enough theory let's see some code now.&lt;/h2&gt;

&lt;p&gt;Above all cases are used in this Play around with the code to get to know more about the &lt;code&gt;useEffect&lt;/code&gt;.&lt;/p&gt;

&lt;h3 id="now-lets-talk-about-the-effects-with-cleanup"&gt;Now let's talk about the Effects with Cleanup&lt;/h3&gt;

&lt;p&gt;These are tricky ones, we already have seen the examples of hooks with clean up but let's see the code part which is provided in an official document, and try to understand it.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;&lt;span class="hljs-function"&gt;&lt;span&gt;function&lt;/span&gt; &lt;span&gt;FriendStatus&lt;/span&gt;(&lt;span&gt;props&lt;/span&gt;) &lt;/span&gt;{&lt;br&gt;
  &lt;span class="hljs-keyword"&gt;const&lt;/span&gt; [isOnline, setIsOnline] = useState(&lt;span class="hljs-literal"&gt;null&lt;/span&gt;);

&lt;p&gt;useEffect(() =&amp;gt; {&lt;br&gt;
   &lt;span&gt;&lt;span&gt;function&lt;/span&gt; &lt;span&gt;handleStatusChange&lt;/span&gt;(&lt;span&gt;status&lt;/span&gt;) &lt;/span&gt;{&lt;br&gt;
      setIsOnline(status.isOnline);&lt;br&gt;
    }&lt;br&gt;
    ChatAPI.subscribeToFriendStatus(props.friend.id, handleStatusChange);&lt;br&gt;
    &lt;span&gt;// Specify how to clean up after this effect:&lt;/span&gt;&lt;br&gt;
    &lt;span&gt;return&lt;/span&gt; &lt;span&gt;&lt;span&gt;function&lt;/span&gt; &lt;span&gt;cleanup&lt;/span&gt;(&lt;span&gt;&lt;/span&gt;) &lt;/span&gt;{&lt;br&gt;
      ChatAPI.unsubscribeFromFriendStatus(props.friend.id, handleStatusChange);&lt;br&gt;
    };&lt;br&gt;
   });&lt;/p&gt;

&lt;p&gt;&lt;span&gt;if&lt;/span&gt; (isOnline === &lt;span&gt;null&lt;/span&gt;) {&lt;br&gt;
    &lt;span&gt;return&lt;/span&gt; &lt;span&gt;'Loading...'&lt;/span&gt;;&lt;br&gt;
   }&lt;br&gt;
   &lt;span&gt;return&lt;/span&gt; isOnline ? &lt;span&gt;'Online'&lt;/span&gt; : &lt;span&gt;'Offline'&lt;/span&gt;;&lt;br&gt;
  }&lt;br&gt;
&lt;/p&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As you can see we are returning a function this is called &lt;code&gt;clean up function&lt;/code&gt;. This is an optional cleanup mechanism for effects so that when your component had been unmounted from the DOM tree it also unsubscribes to the &lt;code&gt;FriendStatus&lt;/code&gt;. As we already know that effects run with every render so this is important to clean up from the previous render also.&lt;/p&gt;

&lt;h2 id="lets-wrap-up"&gt;Let's Wrap up&lt;/h2&gt;

&lt;p&gt;So, we learned three ways how useEffect can be used and we also learned that some effects need cleanups while others don't.&lt;/p&gt;

&lt;p&gt;If you learned something or liked my content follow me on Twitter.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://twitter.com/theysaymaurya?ref_src=twsrc%5Etfw"&gt;Follow @theysaymaurya&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;or &lt;/p&gt;

&lt;p&gt;follow me on Hashnode &lt;a href="https://hashnode.com/@theashishmaurya"&gt;Ashish maurya&lt;/a&gt;&lt;/p&gt;


&lt;p&gt;This blog is posted using &lt;a href="www.blogtiple.com"&gt;Blogtiple&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>functions</category>
      <category>frontend</category>
    </item>
    <item>
      <title>How to Fetch Data From API in ReactJS.</title>
      <dc:creator>Ashish maurya</dc:creator>
      <pubDate>Thu, 24 Feb 2022 08:14:14 +0000</pubDate>
      <link>https://forem.com/theashishmaurya/how-to-fetch-data-from-api-in-reactjs-3m5o</link>
      <guid>https://forem.com/theashishmaurya/how-to-fetch-data-from-api-in-reactjs-3m5o</guid>
      <description>&lt;p&gt;While developing an application in ReactJs you might be asked to fetch some data from an API directly into the frontend and then process it.&lt;/p&gt;

&lt;p&gt;Well just fetching some data from the API is quite easy and today we gonna learn that.&lt;/p&gt;

&lt;h3 id="lets-get-started"&gt;Let's get started&lt;/h3&gt;

&lt;h4 id="first-of-all-lets-create-a-new-react-app"&gt;First of all, let's create a new React app.&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Go to your terminal and copy-paste the below code.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://gist.github.com/Ashumaurya/b48d33db8338b8d0c5edd1e61261e80c" rel="noopener noreferrer"&gt;&lt;/a&gt;&lt;a href="https://gist.github.com/Ashumaurya/b48d33db8338b8d0c5edd1e61261e80c" rel="noopener noreferrer"&gt;https://gist.github.com/Ashumaurya/b48d33db8338b8d0c5edd1e61261e80c&lt;/a&gt;&lt;/p&gt;
&lt;ul&gt;

&lt;li&gt;

&lt;p&gt;Now open the folder in your favorite code editor. (Mine is VS code )&lt;/p&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;Let's use the &lt;code&gt;JSONPLACEHOLDER API&lt;/code&gt;. (It's a dummy rest API for such purposes)&lt;/p&gt;


&lt;/li&gt;

&lt;/ul&gt;
&lt;br&gt;
&lt;a href="https://gist.github.com/Ashumaurya/3f47d91de2b8f2358812af639e26aca9" rel="noopener noreferrer"&gt;&lt;/a&gt;&lt;a href="https://gist.github.com/Ashumaurya/3f47d91de2b8f2358812af639e26aca9" rel="noopener noreferrer"&gt;https://gist.github.com/Ashumaurya/3f47d91de2b8f2358812af639e26aca9&lt;/a&gt;&lt;ul&gt;

&lt;li&gt;

&lt;p&gt;Install the AXIOS library for fetching the data.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://gist.github.com/Ashumaurya/fbd180c4c1d37df398e047ac05556f44" rel="noopener noreferrer"&gt;&lt;/a&gt;&lt;a href="https://gist.github.com/Ashumaurya/fbd180c4c1d37df398e047ac05556f44" rel="noopener noreferrer"&gt;https://gist.github.com/Ashumaurya/fbd180c4c1d37df398e047ac05556f44&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;
&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;After successfully installing the AXIOS let's import it into our app.js
  your app.js should look something like this &lt;/p&gt;


&lt;/li&gt;

&lt;/ul&gt;
&lt;br&gt;
&lt;a href="https://gist.github.com/Ashumaurya/21196bd8f556ee69edebd72f196226d8" rel="noopener noreferrer"&gt;&lt;/a&gt;&lt;a href="https://gist.github.com/Ashumaurya/21196bd8f556ee69edebd72f196226d8" rel="noopener noreferrer"&gt;https://gist.github.com/Ashumaurya/21196bd8f556ee69edebd72f196226d8&lt;/a&gt;&lt;ul&gt;

&lt;li&gt;

&lt;p&gt;Now we are almost done. All we have how to use the Axios inbuilt method &lt;code&gt;Axios.get()&lt;/code&gt; to fetch data from the above API.&lt;/p&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;let's get started by creating a function &lt;code&gt;fetchData&lt;/code&gt; in our &lt;code&gt;App.js&lt;/code&gt;.&lt;/p&gt;


&lt;/li&gt;

&lt;/ul&gt;
&lt;br&gt;
&lt;a href="https://gist.github.com/Ashumaurya/75294e21d750a3fd2c9510c4a8120294" rel="noopener noreferrer"&gt;&lt;/a&gt;&lt;a href="https://gist.github.com/Ashumaurya/75294e21d750a3fd2c9510c4a8120294" rel="noopener noreferrer"&gt;https://gist.github.com/Ashumaurya/75294e21d750a3fd2c9510c4a8120294&lt;/a&gt;&lt;ul&gt;

&lt;li&gt;

&lt;p&gt;Now that we created the function to fetch data from the API, all we need is to call it in our &lt;code&gt;App.js&lt;/code&gt; as soon as DOM renders.&lt;/p&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;We will use &lt;strong&gt;useEffect&lt;/strong&gt; for fetching the data every time DOM renders.&lt;/p&gt;


&lt;/li&gt;

&lt;/ul&gt;
&lt;br&gt;
&lt;a href="https://gist.github.com/Ashumaurya/e160199eab4a9c03e46ebf389ae1ed2a" rel="noopener noreferrer"&gt;&lt;/a&gt;&lt;a href="https://gist.github.com/Ashumaurya/e160199eab4a9c03e46ebf389ae1ed2a" rel="noopener noreferrer"&gt;https://gist.github.com/Ashumaurya/e160199eab4a9c03e46ebf389ae1ed2a&lt;/a&gt;&lt;ul&gt;

&lt;li&gt;If you followed the above steps clearly you would be getting an array of Objects in your developer's console.&lt;/li&gt;

&lt;/ul&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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1625400674380%2FOOCYOQdMGg.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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1625400674380%2FOOCYOQdMGg.png" alt="You would be getting something like above in your developer's console"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Voila!! you have fetched the data from a rest API directly into your React App. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;
Next is creating a TODO APP using React-18 with the above data &lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt; here is my code sandbox link for the above application &lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://codesandbox.io/embed/fetching-dummy-data-from-axios-pubbi?fontsize=14&amp;amp;hidenavigation=1&amp;amp;theme=dark" rel="noopener noreferrer"&gt;&lt;/a&gt;&lt;a href="https://codesandbox.io/embed/fetching-dummy-data-from-axios-pubbi?fontsize=14&amp;amp;hidenavigation=1&amp;amp;theme=dark" rel="noopener noreferrer"&gt;https://codesandbox.io/embed/fetching-dummy-data-from-axios-pubbi?fontsize=14&amp;amp;amp;hidenavigation=1&amp;amp;amp;theme=dark&lt;/a&gt;&lt;/p&gt;

&lt;h2 id="and-guys-do-subscribe-to-my-newsletter"&gt;And guys do subscribe to my newsletter&lt;/h2&gt;


&lt;p&gt;This blog is posted using &lt;a href="www.blogtiple.com"&gt;Blogtiple&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>axios</category>
      <category>restapi</category>
      <category>developer</category>
    </item>
  </channel>
</rss>
