<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by mirbasit01 on Medium]]></title>
        <description><![CDATA[Stories by mirbasit01 on Medium]]></description>
        <link>https://medium.com/@mirbasit01?source=rss-a70f08a1a761------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*SK1m9-d8ms38u3QmxQ7kcw.png</url>
            <title>Stories by mirbasit01 on Medium</title>
            <link>https://medium.com/@mirbasit01?source=rss-a70f08a1a761------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 09:57:22 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mirbasit01/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[React Integration for Beginners: From API Calls to Smart Contracts]]></title>
            <link>https://medium.com/@mirbasit01/react-integration-for-beginners-from-api-calls-to-smart-contracts-6aa70c9c20b4?source=rss-a70f08a1a761------2</link>
            <guid isPermaLink="false">https://medium.com/p/6aa70c9c20b4</guid>
            <category><![CDATA[integration]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[wallet]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[graphql]]></category>
            <dc:creator><![CDATA[mirbasit01]]></dc:creator>
            <pubDate>Thu, 24 Sep 2026 09:15:09 GMT</pubDate>
            <atom:updated>2026-09-24T11:01:25.304Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m-z_kVPKZ2WhokaOdL9xlg.png" /></figure><p>If you already know basic React — components, props, state — the next step is learning how React apps actually <strong>talk to the outside world</strong>: APIs, GraphQL servers, crypto wallets, and smart contracts. This is called “integration,” and it’s exactly what separates a beginner React developer from someone who can build real, production-ready apps.</p><p>This guide is written in plain JavaScript (no TypeScript), and walks through the path step by step:</p><p><strong>API Integration → GraphQL Integration → Wallet Integration → Contract Integration</strong></p><p>Along the way, we’ll cover the React hooks you actually need for this kind of work.</p><h4><strong>Repository:</strong> mirbasit01/Integration-hub on GitHub — every example in this post has working code there. Clone it, run it, and practice each step yourself instead of just reading. <strong>Live demo:</strong> integrationbymirbasit01.netlify.app.</h4><h3>1. The Hooks You Need to Know First</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UX_j1q5l6Hq95JW4BxGebw.png" /></figure><p>Before touching any API or wallet, make sure these hooks feel natural to you. Everything else in this guide builds on top of them.</p><h3>useState</h3><p>Stores data that can change and re-renders your component when it changes.</p><pre>const [user, setUser] = useState(null);</pre><h3>useEffect</h3><p>Runs code when your component loads, or when something changes. This is where most API calls happen.</p><pre>useEffect(() =&gt; {<br>  fetchUser();<br>}, []); // empty array = run once when component mounts</pre><h3>useContext</h3><p>Lets you share data (like a logged-in user, or a wallet connection) across many components without passing props manually at every level.</p><pre>const { user } = useContext(AuthContext);</pre><h3>Custom Hooks</h3><p>A custom hook is just a normal function, whose name starts with use, that reuses logic across components. This is the single most important pattern for integration work.</p><pre>function useUser(id) {<br>  const [user, setUser] = useState(null);<br>  const [loading, setLoading] = useState(true);<br>  const [error, setError] = useState(null);</pre><pre>  useEffect(() =&gt; {<br>    let ignore = false; // guards against a stale response</pre><pre>    setLoading(true);<br>    setError(null);</pre><pre>    fetch(`/api/users/${id}`)<br>      .then((res) =&gt; {<br>        if (!res.ok) throw new Error(`HTTP ${res.status}`);<br>        return res.json();<br>      })<br>      .then((data) =&gt; {<br>        if (!ignore) {<br>          setUser(data);<br>          setLoading(false);<br>        }<br>      })<br>      .catch((err) =&gt; {<br>        if (!ignore) {<br>          setError(err);<br>          setLoading(false);<br>        }<br>      });</pre><pre>    return () =&gt; {<br>      ignore = true; // component unmounted, or id changed — ignore this request<br>    };<br>  }, [id]);</pre><pre>  return { user, loading, error };<br>}</pre><p>Two things matter here that beginners often skip:</p><ul><li><strong>Errors are caught</strong>, not just successes — the hook returns an error value the UI can check.</li><li><strong>The </strong><strong>ignore flag</strong> stops an old request from overwriting newer data. If id changes quickly (say, the user clicks between two profiles), the first request might still be in flight when the second one finishes. Without this guard, the slower, outdated response can land last and show the wrong user.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lui7c75MTYdCoBcotT75NA.png" /></figure><p>Now any component can just do:</p><pre>const { user, loading, error } = useUser(&quot;123&quot;);</pre><h3>useCallback and useMemo</h3><p>These prevent functions and values from being recreated on every render — useful once your app has real API calls and re-renders often.</p><h3>useRef</h3><p>Holds a value that doesn’t trigger a re-render when it changes. Common for things like storing a socket connection or a timer ID.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7MWEkXSdzWw4HuskvWmcXg.png" /></figure><h3>2. Step One: API Integration</h3><p>This is the foundation. Almost every real app needs to fetch or send data to a server.</p><h3>The basic fetch</h3><pre>const response = await fetch(&quot;/api/users&quot;);<br>const data = await response.json();</pre><h3>Don’t scatter fetch() everywhere</h3><p>A common beginner mistake is calling fetch() directly inside every component. Instead, build a small <strong>API client</strong> — one place that knows how to talk to your backend. We&#39;ll use a factory function instead of a class, keeping it consistent with function-based components.</p><pre>function createApiClient(baseURL) {<br>  async function get(path) {<br>    const response = await fetch(`${baseURL}${path}`);<br>    if (!response.ok) {<br>      throw new Error(`HTTP ${response.status}`);<br>    }<br>    return response.json();<br>  }</pre><pre>  async function post(path, body) {<br>    const response = await fetch(`${baseURL}${path}`, {<br>      method: &quot;POST&quot;,<br>      headers: { &quot;Content-Type&quot;: &quot;application/json&quot; },<br>      body: JSON.stringify(body),<br>    });<br>    if (!response.ok) {<br>      throw new Error(`HTTP ${response.status}`);<br>    }<br>    return response.json();<br>  }</pre><pre>  return { get, post };<br>}</pre><pre>const api = createApiClient(&quot;https://api.example.com&quot;);</pre><p>Now every component uses api.get(&quot;/users&quot;) instead of repeating fetch logic. This one change is the beginning of &quot;integration architecture.&quot;</p><h3>Always handle four states</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/889/1*WPHu1bVT1Yv6wCwqkORyDA.png" /></figure><p>Loading, success, empty, and error. Beginners often only handle success — here’s what a real component looks like when it handles all four:</p><pre>function UserList() {<br>  const [users, setUsers] = useState(null);<br>  const [loading, setLoading] = useState(true);<br>  const [error, setError] = useState(null);</pre><pre>  useEffect(() =&gt; {<br>    setLoading(true);<br>    api.get(&quot;/users&quot;)<br>      .then((data) =&gt; setUsers(data))<br>      .catch((err) =&gt; setError(err))<br>      .finally(() =&gt; setLoading(false));<br>  }, []);</pre><pre>  if (loading) return &lt;Spinner /&gt;;<br>  if (error) return &lt;ErrorMessage message={error.message} /&gt;;<br>  if (!users || users.length === 0) return &lt;EmptyState text=&quot;No users yet&quot; /&gt;;</pre><pre>  return (<br>    &lt;ul&gt;<br>      {users.map((u) =&gt; (<br>        &lt;li key={u.id}&gt;{u.name}&lt;/li&gt;<br>      ))}<br>    &lt;/ul&gt;<br>  );<br>}</pre><p>Notice the order: check loading first, then error, then empty, and only then render the real data. Skipping any of these is how beginners end up with blank screens or crashes when the API is slow, fails, or simply returns nothing.</p><h3>3. Step Two: GraphQL Integration</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xezKfGWFkl2Q9qXMwM62Lg.png" /></figure><p>GraphQL is an alternative to REST where the client asks for exactly the fields it needs.</p><h3>A basic query</h3><pre>query GetUser($id: ID!) {<br>  user(id: $id) {<br>    id<br>    name<br>    email<br>  }<br>}</pre><h3>Using it in React with fetch (no extra library)</h3><pre>async function fetchUser(id) {<br>  const response = await fetch(&quot;/graphql&quot;, {<br>    method: &quot;POST&quot;,<br>    headers: { &quot;Content-Type&quot;: &quot;application/json&quot; },<br>    body: JSON.stringify({<br>      query: `<br>        query GetUser($id: ID!) {<br>          user(id: $id) { id name email }<br>        }<br>      `,<br>      variables: { id },<br>    }),<br>  });</pre><pre>  if (!response.ok) {<br>    throw new Error(`Network error: HTTP ${response.status}`);<br>  }</pre><pre>  const { data, errors } = await response.json();</pre><pre>  // GraphQL has its own error format — a request can return HTTP 200<br>  // and still contain errors, so this check is easy to miss.<br>  if (errors &amp;&amp; errors.length &gt; 0) {<br>    throw new Error(errors[0].message);<br>  }</pre><pre>  return data.user;<br>}</pre><p>Notice there are <strong>two different kinds of failure</strong> to handle: a network/HTTP failure (!response.ok), and a GraphQL-level failure, which comes back inside a normal 200 response as an errors array. Checking only response.ok and skipping errors is a very common beginner bug in GraphQL apps.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zBwHzOXR_jvGYt-58FgV3Q.png" /></figure><p>Later, once you’re comfortable, tools like Apollo Client or urql handle caching and re-fetching for you — but understanding the raw request first is important.</p><h3>4. Step Three: Wallet Integration</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W9rgotM9utMtn5vJb9EWAQ.png" /></figure><p>If your app talks to blockchains, the first integration point is connecting a user’s wallet (like MetaMask).</p><h3>The basic idea</h3><pre>async function connectWallet() {<br>  if (!window.ethereum) {<br>    alert(&quot;Please install MetaMask&quot;);<br>    return;<br>  }</pre><pre>  const accounts = await window.ethereum.request({<br>    method: &quot;eth_requestAccounts&quot;,<br>  });</pre><pre>  return accounts[0]; // the connected wallet address<br>}</pre><h3>As a custom hook</h3><pre>function useWallet() {<br>  const [address, setAddress] = useState(null);</pre><pre>  async function connect() {<br>    const accounts = await window.ethereum.request({<br>      method: &quot;eth_requestAccounts&quot;,<br>    });<br>    setAddress(accounts[0]);<br>  }</pre><pre>  return { address, connect };<br>}</pre><p>In real projects, libraries like <strong>wagmi</strong> and <strong>viem</strong> handle wallet connection, network switching, and account changes for you — but this raw version is what they do under the hood.</p><h3>5. Step Four: Smart Contract Integration</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EF7HViiyl5UhBzYfLbvsnA.png" /></figure><p>Once a wallet is connected, you can read from and write to smart contracts. Both readContract and writeContract need a client — this is what actually talks to the blockchain, and it&#39;s set up once, outside your components:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r4YIJ1w4GjJ1xcGfp7-PBw.png" /></figure><pre>import { createPublicClient, createWalletClient, custom, http } from &quot;viem&quot;;<br>import { mainnet } from &quot;viem/chains&quot;;</pre><pre>// Public client — for reads. No wallet needed, just an RPC connection.<br>const publicClient = createPublicClient({<br>  chain: mainnet,<br>  transport: http(),<br>});</pre><pre>// Wallet client — for writes. Wraps the connected wallet (e.g. MetaMask).<br>const walletClient = createWalletClient({<br>  chain: mainnet,<br>  transport: custom(window.ethereum),<br>});</pre><h3>Reading data (no wallet signature needed)</h3><pre>import { readContract } from &quot;viem/actions&quot;;</pre><pre>async function getBalance(address) {<br>  const balance = await readContract(publicClient, {<br>    address: contractAddress,<br>    abi: contractAbi,<br>    functionName: &quot;balanceOf&quot;,<br>    args: [address],<br>  });<br>  return balance;<br>}</pre><p>A read only needs the publicClient — the user doesn&#39;t even need a wallet connected to see this data, since it&#39;s just querying public chain state.</p><h3>Writing data (requires wallet confirmation)</h3><pre>async function transferTokens(to, amount) {<br>  const hash = await writeContract(walletClient, {<br>    address: contractAddress,<br>    abi: contractAbi,<br>    functionName: &quot;transfer&quot;,<br>    args: [to, amount],<br>  });<br>  return hash;<br>}</pre><p>A write needs the walletClient instead, because it has to be signed by the user&#39;s connected wallet.</p><p>The key idea: <strong>reads are free and instant</strong>, <strong>writes cost gas and need user approval</strong>. Your UI should treat these very differently — writes need loading states, confirmations, and error handling for rejected transactions.</p><h3>Recap: The Path</h3><pre>API Integration<br>      ↓<br>GraphQL Integration<br>      ↓<br>Wallet Integration<br>      ↓<br>Contract Integration</pre><p>Don’t try to master all four at once. Start by building a small API client, wrap it in one custom hook, and use it in a real component. Once that feels natural, move to the next layer. Each step builds directly on the one before it — and by the end, you won’t just be “using” integrations, you’ll be able to build them for other developers too.</p><p><a href="https://medium.com/u/a70f08a1a761">mirbasit01</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6aa70c9c20b4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Code Reusability: A Lesson from 3.5 Years of Coding]]></title>
            <link>https://medium.com/@mirbasit01/code-reusability-a-lesson-from-3-5-years-of-coding-ed633fd2880a?source=rss-a70f08a1a761------2</link>
            <guid isPermaLink="false">https://medium.com/p/ed633fd2880a</guid>
            <category><![CDATA[code]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[reactjs]]></category>
            <dc:creator><![CDATA[mirbasit01]]></dc:creator>
            <pubDate>Fri, 28 Aug 2026 16:56:05 GMT</pubDate>
            <atom:updated>2026-08-28T16:56:05.462Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GGL_qqNX6LPX-XFGmxOfdw.png" /></figure><p>One thing I’ve learned over my 3.5 years of experience is this: code reusability matters more than almost anything else you’ll practice as a developer.</p><p>It’s especially true when it comes to API integrations. Here’s the structure I always follow:</p><p>📁 utils/ ├── services/ → all API functions live here (fetch, post, update, delete — each exported separately) └── constants/ → all API endpoints and static content live here</p><p>Instead of hardcoding endpoints or writing fetch calls directly inside components:</p><p>✅ Keep your API functions in a services file and export them ✅ Keep your endpoint URLs and static values in a constants file ✅ Import and reuse them wherever needed — no duplication, no guesswork</p><p>Why this matters: ❌ No more hunting through components to find where an endpoint is used ❌ No more copy-pasting the same fetch logic in five different files ❌ One place to update if an API URL changes ✅ Cleaner components that only handle UI logic ✅ Easier testing, debugging, and onboarding for new devs</p><p>This one habit alone has saved me countless hours on every project I’ve worked on.</p><p>💡 Reusable code isn’t just clean code — it’s code that respects your future self’s time.</p><p>#WebDevelopment #JavaScript #ReactJS #CodingBestPractices #APIIntegration #CleanCode #FrontendDevelopment</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed633fd2880a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React.js Tip: Keep Your Components Clean]]></title>
            <link>https://medium.com/@mirbasit01/react-js-tip-keep-your-components-clean-a2ddfc50162e?source=rss-a70f08a1a761------2</link>
            <guid isPermaLink="false">https://medium.com/p/a2ddfc50162e</guid>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[typescript]]></category>
            <dc:creator><![CDATA[mirbasit01]]></dc:creator>
            <pubDate>Fri, 28 Aug 2026 16:43:29 GMT</pubDate>
            <atom:updated>2026-08-28T16:43:29.198Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-DRfu7OHrpwAhe1VDehqzA.png" /></figure><p>Big components are a trap.</p><p>They start small, then one day you open the file and it’s 400 lines of state, fetch calls, form logic, and JSX — all tangled together.</p><p>Too much logic in one place Hard to maintain Difficult to debug Impossible to reuse anywhere else</p><p>The fix: break your UI into smaller, focused components.</p><p>Instead of one giant Dashboard.jsx handling everything, split it into:</p><pre>Dashboard.jsx<br> ├── Header.jsx<br> ├── Sidebar.jsx<br> ├── StatsPanel.jsx<br> └── ActivityFeed.jsx</pre><p>Each one does exactly one thing — and each one is easy to test, reuse, and reason about on its own.</p><p>Better code structure Easier maintenance Easier debugging Better scalability</p><p>A simple rule I follow: if a component’s file is hard to summarize in one sentence, it’s probably doing too much.</p><p>This is one of the patterns I rely on constantly while building with React, Next.js, and TypeScript.</p><p>Clean code today makes development easier tomorrow.</p><p>#ReactJS #NextJS #TypeScript #FrontendDevelopment #WebDevelopment #JavaScript #Coding #Web3</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a2ddfc50162e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What Is Phaser]]></title>
            <link>https://medium.com/@mirbasit01/what-is-phaser-81a16dea56e6?source=rss-a70f08a1a761------2</link>
            <guid isPermaLink="false">https://medium.com/p/81a16dea56e6</guid>
            <category><![CDATA[2d-animation]]></category>
            <category><![CDATA[phaserjs]]></category>
            <category><![CDATA[reacctjs]]></category>
            <category><![CDATA[nextjs]]></category>
            <dc:creator><![CDATA[mirbasit01]]></dc:creator>
            <pubDate>Thu, 13 Aug 2026 15:06:02 GMT</pubDate>
            <atom:updated>2026-08-13T15:06:02.477Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-G-HYqPIl3zaG82ODIE8fA.png" /></figure><h3>Phaser 4: What It Is and How to Use It in React.js / Next.js</h3><p>If you’ve ever wanted to build a browser game — from a simple platformer to a full 2D world with physics, particles, and lighting — chances are you’ve bumped into <strong>Phaser</strong>. It’s one of the most popular open-source HTML5 game frameworks out there, and it just received its biggest update ever: <strong>Phaser 4</strong>.</p><p>In this post, I’ll cover what Phaser actually is, what’s new in version 4, and then walk through a clean, production-ready way to drop a Phaser game inside a <strong>React</strong> or <strong>Next.js</strong> app.</p><h3>What Is Phaser?</h3><p>Phaser is a free, open-source JavaScript/TypeScript framework for building 2D games that run in the browser (and, via wrappers, on mobile and desktop too). It’s been in active development for over a decade, created by Richard Davey and maintained by Phaser Studio, and it’s been used to ship everything from game-jam prototypes to full commercial titles.</p><p>Out of the box, Phaser gives you:</p><ul><li>A <strong>scene system</strong> for organizing game states (menu, level, game over, etc.)</li><li><strong>Physics engines</strong> (Arcade Physics, Matter.js)</li><li><strong>Sprites, tweens, cameras, particles, and animations</strong></li><li><strong>Input handling</strong> for keyboard, mouse, touch, and gamepad</li><li><strong>Asset loading</strong> for images, spritesheets, audio, and tilemaps</li><li>Automatic switching between <strong>Canvas</strong> and <strong>WebGL</strong> rendering depending on browser support</li></ul><p>Basically, it’s everything you’d need to build a 2D game without writing your own renderer or physics engine from scratch.</p><h3>What’s New in Phaser 4</h3><p>Phaser 4 isn’t a rewrite from the ground up — the public API is largely the same as Phaser 3, so existing knowledge carries over. But under the hood, it’s a massive overhaul, described by the team as the biggest release in the framework’s history. The highlights:</p><ul><li><strong>A brand-new WebGL renderer.</strong> The old pipeline system from v3 has been replaced with a <strong>node-based render architecture</strong>, where each render node handles one job. This makes the renderer faster, more reliable, and easier to extend, and it properly manages WebGL state and context loss.</li><li><strong>A unified Filter system.</strong> FX and Masks from v3 have been merged into one Filter system you can apply to any game object or camera, with built-in effects like Blur, Glow, Shadow, Pixelate, Bloom, Vignette, and more.</li><li><strong>SpriteGPULayer.</strong> A new way to render huge numbers of sprites — up to a million in a single draw call — dramatically faster than standard rendering.</li><li><strong>Improved lighting</strong>, including self-shadows, with an API as simple as sprite.setLighting(true).</li><li><strong>Big mobile performance gains</strong>, including major reductions in memory usage from an overhauled buffer system for filters and masks.</li><li><strong>AI-agent-friendly tooling.</strong> The Phaser repo ships with dozens of “skill” files documenting every subsystem, plus a dedicated v3-to-v4 migration skill, meant to help AI coding assistants generate correct, idiomatic Phaser 4 code.</li></ul><p>If you’re on Phaser 3, the team provides a full migration guide, since there are some breaking changes (renderer internals, the tint system, the FX/Mask API, and a few removed classes).</p><h3>Using Phaser 4 in React or Next.js</h3><p>Phaser wasn’t designed with React in mind — it wants to own a &lt;canvas&gt; element and run its own game loop. React wants to own the DOM and re-render declaratively. The trick to combining them is simple: <strong>let Phaser manage its own canvas inside a container </strong><strong>div, and use React only to mount/unmount that container.</strong> Don&#39;t try to make Phaser &quot;reactive&quot; — treat it as an imperative library React just happens to host.</p><h3>1. Install Phaser</h3><pre>npm install phaser</pre><h3>2. Create the Phaser game instance in its own file</h3><p>Keep your Phaser config and scene logic separate from your React components. This keeps things clean and makes the code portable.</p><pre>// game/MainScene.js<br>import Phaser from &quot;phaser&quot;;</pre><pre>export class MainScene extends Phaser.Scene {<br>  constructor() {<br>    super(&quot;MainScene&quot;);<br>  }</pre><pre>  preload() {<br>    this.load.image(&quot;logo&quot;, &quot;/assets/logo.png&quot;);<br>  }</pre><pre>  create() {<br>    this.add.image(400, 300, &quot;logo&quot;);</pre><pre>    this.tweens.add({<br>      targets: this.children.list[0],<br>      y: 350,<br>      duration: 1000,<br>      ease: &quot;Sine.easeInOut&quot;,<br>      yoyo: true,<br>      repeat: -1,<br>    });<br>  }<br>}</pre><pre>// game/config.js<br>import { MainScene } from &quot;./MainScene&quot;;</pre><pre>export const createGameConfig = (parent) =&gt; ({<br>  type: Phaser.AUTO,<br>  width: 800,<br>  height: 600,<br>  parent,<br>  scene: [MainScene],<br>  physics: {<br>    default: &quot;arcade&quot;,<br>    arcade: { gravity: { y: 0 } },<br>  },<br>});</pre><h3>3. Wrap it in a React component</h3><p>This is the key piece. Use a ref for the container div, and create/destroy the Phaser game inside useEffect.</p><pre>// components/PhaserGame.jsx<br>&quot;use client&quot;; // only needed in Next.js App Router</pre><pre>import { useEffect, useRef } from &quot;react&quot;;<br>import Phaser from &quot;phaser&quot;;<br>import { MainScene } from &quot;@/game/MainScene&quot;;</pre><pre>export default function PhaserGame() {<br>  const gameRef = useRef(null);<br>  const containerRef = useRef(null);</pre><pre>  useEffect(() =&gt; {<br>    if (gameRef.current) return; // avoid double-init in React StrictMode</pre><pre>    gameRef.current = new Phaser.Game({<br>      type: Phaser.AUTO,<br>      width: 800,<br>      height: 600,<br>      parent: containerRef.current,<br>      scene: [MainScene],<br>      physics: {<br>        default: &quot;arcade&quot;,<br>        arcade: { gravity: { y: 0 } },<br>      },<br>    });</pre><pre>    return () =&gt; {<br>      gameRef.current?.destroy(true);<br>      gameRef.current = null;<br>    };<br>  }, []);</pre><pre>  return &lt;div ref={containerRef} /&gt;;<br>}</pre><p>A few things worth calling out:</p><ul><li><strong>useRef instead of </strong><strong>useState</strong> for the game instance — you never want Phaser&#39;s existence to trigger a React re-render.</li><li><strong>Cleanup in the </strong><strong>useEffect return function</strong> is essential. Without game.destroy(true), you&#39;ll leak WebGL contexts and get &quot;duplicate canvas&quot; bugs, especially in dev mode with hot reloading.</li><li><strong>The </strong><strong>if (gameRef.current) return guard</strong> protects against React 18&#39;s StrictMode, which intentionally double-invokes effects in development.</li></ul><h3>4. Handling Next.js and SSR</h3><p>Phaser touches window and other browser-only APIs, so it can&#39;t run during server-side rendering. In the <strong>App Router</strong>, the &quot;use client&quot; directive at the top of the component (shown above) is usually enough, since the actual Phaser code only runs inside useEffect, which never executes on the server.</p><p>If you still hit SSR errors (common with some Phaser plugins or if you import Phaser at the top of a page instead of inside a client component), load the game component dynamically with SSR disabled:</p><pre>// app/game/page.jsx<br>import dynamic from &quot;next/dynamic&quot;;</pre><pre>const PhaserGame = dynamic(() =&gt; import(&quot;@/components/PhaserGame&quot;), {<br>  ssr: false,<br>});</pre><pre>export default function GamePage() {<br>  return &lt;PhaserGame /&gt;;<br>}</pre><h3>5. Talking between React and Phaser</h3><p>Eventually you’ll want your React UI (score displays, menus, modals) to communicate with the game. The cleanest way is Phaser’s built-in <strong>EventEmitter</strong>, rather than trying to pass React props into game objects.</p><pre>// inside a Phaser Scene<br>this.events.emit(&quot;score-updated&quot;, newScore);</pre><pre>// in your React component<br>useEffect(() =&gt; {<br>  const scene = gameRef.current?.scene.getScene(&quot;MainScene&quot;);<br>  const handleScore = (score) =&gt; setScore(score);<br>  scene?.events.on(&quot;score-updated&quot;, handleScore);<br>  return () =&gt; scene?.events.off(&quot;score-updated&quot;, handleScore);<br>}, []);</pre><p>This keeps Phaser and React loosely coupled — Phaser doesn’t know React exists, and React just listens for events.</p><h3>Example Projects to Learn From</h3><p>If you want to see these patterns in real codebases rather than isolated snippets, here are two community repos worth cloning:</p><ul><li><strong>React.js example:</strong> <a href="https://github.com/mirbasit01/Phaser-React-Games">Phaser-React-Games</a> by mirbasit01 — a set of small Phaser games wired into plain React (Create React App style), useful for seeing the container-div + useEffect pattern applied across multiple game examples.</li><li><strong>Next.js example:</strong> if you’re looking for a Next.js starter, the official <a href="https://github.com/phaserjs/template-nextjs">phaserjs/template-nextjs</a> is the safest bet — it’s maintained by the Phaser team and already includes a React-to-Phaser event bridge, hot reloading, and production build scripts. <em>(Note: the “Gamivox” repo you linked — </em><em>hamzaAli0108/Gamivox — returned a 404, so it looks like it may have been renamed, deleted, or made private. Double-check the URL, and I&#39;m happy to look at it once it&#39;s accessible.)</em></li></ul><h3>Wrapping Up</h3><p>Phaser 4 is a huge step forward for browser-based game development: a rebuilt renderer, unified filters, GPU-driven sprite batching, and meaningful mobile performance gains, all while keeping the API you already know. Dropping it into React or Next.js comes down to one principle: <strong>let Phaser own the canvas, and let React just mount and unmount the container.</strong> Once that boundary is set up cleanly with refs and useEffect, you get the best of both — React for your app shell and UI, Phaser for the game itself.</p><p>From here, a natural next step is wiring up Arcade Physics for collisions, loading a tilemap for a real level, or trying out Phaser 4’s new lighting and filter effects on your sprites.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=81a16dea56e6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Your Transaction Shows “Failed” But Your Money Is Already Gone]]></title>
            <link>https://medium.com/@mirbasit01/why-your-transaction-shows-failed-but-your-money-is-already-gone-1f94cededd95?source=rss-a70f08a1a761------2</link>
            <guid isPermaLink="false">https://medium.com/p/1f94cededd95</guid>
            <category><![CDATA[web3]]></category>
            <category><![CDATA[transaction-failed]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[mirbasit01]]></dc:creator>
            <pubDate>Thu, 18 Jun 2026 22:51:50 GMT</pubDate>
            <atom:updated>2026-06-18T22:51:50.916Z</atom:updated>
            <content:encoded><![CDATA[<p><em>A deep dive into two silent bugs that combine to show a false failure while your transaction already landed on-chain.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VcbjJTcuWmyaZTwDsKrknw.png" /><figcaption>@mirbasit01</figcaption></figure><h3>The Scenario</h3><p>You submit a transaction. Everything looks normal. You wait.</p><p>Then you see it — <strong>“Transaction Failed.”</strong></p><p>But your wallet balance already dropped. The funds moved. Something happened on-chain. Yet the UI is telling you it failed.</p><p>You try again. Now you get a cryptic error you’ve never seen before:</p><pre>InternalRpcError: An internal error was received<br>Details: validation reverted<br>Reason: AA25 invalid account nonce</pre><p>This is not a one-off glitch. This is the result of two separate bugs hitting at exactly the same time — and neither one is obvious on its own.</p><h3>What Actually Happened (Step by Step)</h3><p>Here is the exact sequence of events at runtime:</p><p><strong>Step 1 — Transaction submits successfully ✅</strong> sendPreparedCalls executes. The UserOperation is sent to the bundler. It lands on-chain. Nonce 8 is consumed. Funds are moved. Everything at the blockchain level is complete.</p><p><strong>Step 2 — On-chain state is updated ✅</strong> The transaction is confirmed. From the blockchain’s perspective, everything worked perfectly.</p><p><strong>Step 3 — Status check throws a CORS error ❌</strong> getCallsStatus() is called directly from the browser to check the transaction status. But the deployment domain is not whitelisted in the Alchemy dashboard. The browser blocks the request entirely — CORS policy violation.</p><p><strong>Step 4 — UI displays “Transaction Failed” ❌</strong> The catch block re-throws the CORS error. The frontend has no way to distinguish a CORS failure from a transaction failure. It treats them the same. The user sees a false error message.</p><p><strong>Step 5 — User retries → AA25 rejected ❌</strong> prepareCalls is called again. It returns nonce 8 — the same stale nonce. The bundler rejects it immediately with AA25 invalid account nonce because that nonce is already used on-chain. Every retry fails. There is no recovery path.</p><p><strong>End result:</strong> Transaction succeeded ✅ — Money moved ✅ — UI says Failed ❌ — Every retry also fails ❌</p><h3>The Two Root Causes</h3><h3>Bug 01 — AA25 Invalid Account Nonce</h3><p>In ERC-4337 Account Abstraction, every UserOperation must include a nonce that matches the account’s current on-chain nonce. When a transaction lands on-chain, that nonce is consumed and can never be reused.</p><p>The problem: there was no retry logic in the code. When sendPreparedCalls threw an error (even a CORS error unrelated to the transaction itself), the entire flow crashed. The next attempt called prepareCalls again — but Alchemy returned the same stale nonce 8, because the frontend had no mechanism to detect that this nonce was already used.</p><p>The bundler then correctly rejected the operation with AA25 invalid account nonce.</p><p>This can also happen due to:</p><ul><li>The same transaction function being called multiple times (duplicate API calls)</li><li>A user double-clicking the submit button</li><li>React useEffect or event listeners triggering multiple times</li><li>Multiple browser tabs using the same wallet simultaneously</li></ul><h3>Bug 02 — CORS Misconfiguration</h3><p>The Alchemy API was being called directly from the browser. But the deployment domain (your-app.amplifyapp.com) was not added to the Alchemy dashboard&#39;s Allowed Origins list.</p><p>When getCallsStatus() ran after a successful transaction, the browser blocked the request:</p><pre>Access to fetch at &#39;https://api.g.alchemy.com/v2&#39; <br>has been blocked by CORS policy: <br>No &#39;Access-Control-Allow-Origin&#39; header is present</pre><p>Notice the response code: net::ERR_FAILED 200 (OK) — Alchemy actually returned a successful response. But the browser blocked it before the JavaScript could read it. The UI had no way to know the transaction succeeded.</p><h3>Why These Two Bugs Are Hard to Catch Separately</h3><p>Individually, each bug gives you a clear signal:</p><ul><li><strong>AA25 alone</strong> → you would immediately see a nonce error and investigate duplicate calls</li><li><strong>CORS alone</strong> → you would see the blocked request and whitelist your domain</li></ul><p>But together, CORS masks the transaction success, which causes the user to retry, which triggers AA25. The AA25 error then dominates the logs, making developers chase the wrong root cause first.</p><h3>The Fix</h3><h3>Fix 01 — Add Retry Logic for AA25 (Code Change)</h3><p>Wrap the prepare → sign → send flow inside a retry helper function. When an AA25 error is detected, re-call prepareCalls to fetch a fresh nonce from Alchemy, then retry the full operation — up to 3 attempts.</p><pre>async function prepareSignAndSend(buildCalls, maxRetries = 3) {<br>  for (let attempt = 0; attempt &lt; maxRetries; attempt++) {<br>    try {<br>      const preparedCalls = await smartAccountClient.prepareCalls(buildCalls());<br>      const signedCalls = await signPreparedCalls(sessionKey, preparedCalls);<br>      return await smartAccountClient.sendPreparedCalls(signedCalls);<br>    } catch (error) {<br>      const isNonceError = error?.message?.includes(&#39;AA25&#39;);<br>      if (isNonceError &amp;&amp; attempt &lt; maxRetries - 1) {<br>        await new Promise(r =&gt; setTimeout(r, 300));<br>        continue; // retry with fresh nonce<br>      }<br>      throw error;<br>    }<br>  }<br>}</pre><p>This ensures a stale nonce never permanently kills a transaction flow.</p><h3>Fix 02 — Whitelist Your Domain in Alchemy (Dashboard Config)</h3><ol><li>Go to <a href="https://dashboard.alchemy.com/">dashboard.alchemy.com</a></li><li>Select your app / API key (the one used for your chain)</li><li>Navigate to <strong>Security → Allowed Origins</strong></li><li>Add your deployment domain: <a href="https://your-app.amplifyapp.com/">https://your-app.amplifyapp.com</a></li><li>Also add your production domain if different</li></ol><p>Without this fix, getCallsStatus will keep failing with CORS after every successful transaction — meaning the UI will never correctly confirm a transaction from the browser.</p><h3>Checklist Before You Ship</h3><ul><li>[ ] Transaction submit function is called only once per user action</li><li>[ ] Submit button is disabled immediately on first click</li><li>[ ] Retry-on-AA25 logic added with fresh nonce re-fetch</li><li>[ ] All deployment domains whitelisted in Alchemy Allowed Origins (staging + production)</li><li>[ ] Status check failure is handled separately from transaction failure in catch block</li><li>[ ] Nonce value is logged before every sendPreparedCalls call during debugging</li></ul><h3>Key Takeaway</h3><blockquote><em>These two bugs are easy to miss individually. Their real damage only becomes visible when they collide at runtime — one hides the success, the other punishes every retry.</em></blockquote><p>If your users are reporting that their transaction failed but their balance dropped, check these two things first:</p><ol><li>Is your domain whitelisted in your RPC provider’s CORS settings?</li><li>Does your transaction flow have nonce retry logic for AA25 errors?</li></ol><p>Fix both. Neither one alone is enough.</p><p><em>Tags: #Web3 #Blockchain #Debugging #ERC4337 #AccountAbstraction #Alchemy #JavaScript #DeFi</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1f94cededd95" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Transaction shows “Failed”
but money was already gone]]></title>
            <link>https://medium.com/@mirbasit01/transaction-shows-failed-but-money-was-already-gone-78f9619c5c33?source=rss-a70f08a1a761------2</link>
            <guid isPermaLink="false">https://medium.com/p/78f9619c5c33</guid>
            <category><![CDATA[web3]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[alchemy]]></category>
            <category><![CDATA[reacct]]></category>
            <category><![CDATA[frontend]]></category>
            <dc:creator><![CDATA[mirbasit01]]></dc:creator>
            <pubDate>Thu, 18 Jun 2026 22:48:05 GMT</pubDate>
            <atom:updated>2026-06-18T22:48:05.653Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tUeCZefPj2nM1rMtq2JyBA.png" /><figcaption>Transaction shows “Failed”<br>but money was already gone</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=78f9619c5c33" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What Is Account Abstraction?]]></title>
            <link>https://medium.com/@mirbasit01/what-is-account-abstraction-740bb6233169?source=rss-a70f08a1a761------2</link>
            <guid isPermaLink="false">https://medium.com/p/740bb6233169</guid>
            <category><![CDATA[account-abstraction]]></category>
            <category><![CDATA[web3]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[aaaccount]]></category>
            <category><![CDATA[frontend]]></category>
            <dc:creator><![CDATA[mirbasit01]]></dc:creator>
            <pubDate>Tue, 17 Feb 2026 13:30:04 GMT</pubDate>
            <atom:updated>2026-02-17T13:30:04.620Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Account Abstraction</strong> means:</p><p><em>Turning a normal wallet account into a programmable smart contract account.</em></p><p>In simple words:</p><p>Instead of using a normal EOA wallet (like MetaMask),<br> you use a <strong>smart contract wallet</strong> that can control how transactions work.</p><h3>Normal Ethereum Accounts (Before AA)</h3><p>Ethereum has 2 types of accounts:</p><p><strong>EOA (Externally Owned Account)</strong></p><p>Controlled by private key</p><p>Example: MetaMask wallet</p><p>Can only send transactions signed by user</p><p><strong>Smart Contract Account</strong></p><p>Controlled by code</p><p>Cannot initiate transactions by itself</p><p>Problem:</p><p>EOA must pay gas</p><p>Private key = single point of failure</p><p>No custom logic</p><p>No social recovery</p><p>No gas sponsorship</p><h3>Account Abstraction (ERC-4337)</h3><p>With <strong>ERC-4337</strong>, smart contracts can behave like wallets.</p><p>Your wallet becomes a smart contract.</p><p>You don’t send normal transactions anymore.<br> You send something called:</p><h3>🧾 UserOperation</h3><p>Instead of:</p><pre>eth_sendTransaction</pre><p>You send:</p><pre>UserOperation</pre><p>Then a <strong>Bundler</strong> includes it in a block.</p><h3>⚙️ How AA Works (Flow)</h3><p>User → Wallet (Smart Contract) → Bundler → EntryPoint → Blockchain</p><p>Steps:</p><p>User signs a <strong>UserOperation</strong></p><p>Bundler collects operations</p><p>Bundler calls EntryPoint</p><p>EntryPoint executes your smart wallet</p><h3>Why Account Abstraction Is Powerful</h3><h3>1. Gas Fee in Any Token</h3><p>User can pay gas in:</p><p>USDT</p><p>USDC</p><p>DAI</p><p>Even project token</p><p>(No need to hold ETH)</p><h3>2. Gasless Transactions (Paymaster)</h3><p>A <strong>Paymaster</strong> can sponsor gas.</p><p>Example:</p><p>User signs transaction</p><p>DApp pays gas</p><p>User pays nothing</p><p>Perfect for Web2-like UX.</p><h3>3. Social Recovery</h3><p>Instead of:</p><pre>Private key lost = funds gone forever</pre><p>You can:</p><p>Add guardians</p><p>Recover wallet with 2/3 approvals</p><h3>4. Multi-Sig Built-In</h3><p>Wallet can require:</p><p>2 signatures</p><p>3 approvals</p><p>Time delay</p><p>Custom rules</p><p>All programmable.</p><h3>5. Batch Transactions</h3><p>User can:</p><p>Approve token</p><p>Swap token</p><p>Stake token</p><p>All in ONE transaction.</p><h3>Technical Components (Important for You)</h3><h3>🟢 EntryPoint Contract</h3><p>Main contract that processes UserOperations.</p><h3>🟢 Bundler</h3><p>Like a special node that includes AA transactions.</p><h3>🟢 Paymaster</h3><p>Pays gas for user.</p><h3>EOA vs Account Abstraction</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/879/1*4pc5I1r7475ykfj__HraNQ.png" /></figure><h3>Real Projects Using Account Abstraction</h3><p>Safe (Smart Contract Wallet)</p><p>zkSync Native AA</p><p>Starknet Native AA</p><p>Base + ERC-4337 wallets</p><h3>As a Frontend Dev (wagmi + ethers)</h3><p>Instead of normal:</p><pre>const { writeContract } = useWriteContract()</pre><p>With AA you use:</p><p>smart account SDK</p><p>bundler RPC</p><p>createUserOperation()</p><p>sendUserOperation()</p><p>Libraries:</p><p>Biconomy SDK</p><p>ZeroDev SDK</p><p>Safe Core SDK</p><p>Alchemy AA SDK</p><h3>Simple Real Example</h3><p>User wants to swap USDC → ETH</p><p>Without AA:</p><p>User must hold ETH for gas</p><p>With AA:</p><p>User holds only USDC</p><p>Paymaster pays gas</p><p>Or gas deducted from USDC</p><p>Better UX = Web2-like experience</p><h3>Why AA Is Important for Future Web3</h3><p>Account Abstraction makes:</p><p>Wallets smarter</p><p>UX better</p><p>Mass adoption possible</p><p>Web2-style onboarding</p><p>Most new Web3 apps are moving toward AA.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=740bb6233169" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React Performance Optimization: useMemo vs useCallback]]></title>
            <link>https://medium.com/@mirbasit01/react-performance-optimization-usememo-vs-usecallback-1f5741bfc86b?source=rss-a70f08a1a761------2</link>
            <guid isPermaLink="false">https://medium.com/p/1f5741bfc86b</guid>
            <category><![CDATA[usecallback]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[react-hook]]></category>
            <category><![CDATA[usememo]]></category>
            <category><![CDATA[frontend]]></category>
            <dc:creator><![CDATA[mirbasit01]]></dc:creator>
            <pubDate>Mon, 19 Jan 2026 13:12:22 GMT</pubDate>
            <atom:updated>2026-01-19T13:13:21.395Z</atom:updated>
            <content:encoded><![CDATA[<h3>useMemo vs useCallback</h3><h3>Understanding when to cache values and when to cache functions</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WwEdsRYKdOV9UQ_k0dQsaw.png" /></figure><h3>Introduction</h3><p>React provides two important hooks for performance optimization: <strong>useMemo</strong> and <strong>useCallback</strong>. Both hooks are used for memoization, but they serve different purposes. This blog post will give you a clear understanding of when to use which hook.</p><h3>What is Memoization?</h3><p>Memoization is an optimization technique that caches the results of expensive calculations or operations. When the same inputs occur again, the cached result is returned instead of recalculating. This improves performance and reduces unnecessary re-renders.</p><h3>useMemo: For Caching Values</h3><p>The <strong>useMemo</strong> hook caches the <strong><em>result</em></strong> of expensive calculations. It’s used for numbers, arrays, objects, or any computed value.</p><h3>Syntax</h3><pre>const memoizedValue = useMemo(() =&gt; computeExpensiveValue(a, b), [a, b]);</pre><h3>Use Cases</h3><ul><li><strong>Heavy calculations</strong>: When a calculation is computationally expensive</li><li><strong>Filtered arrays</strong>: Filtering or sorting large arrays</li><li><strong>Derived state</strong>: Creating computed values from props</li><li><strong>Reference stability</strong>: Keeping objects or arrays reference-stable</li></ul><h3>Example</h3><pre>import { useMemo, useState } from &#39;react&#39;;</pre><pre>function ProductList({ products }) {<br>  const [filter, setFilter] = useState(&#39;&#39;);</pre><pre>  // Cache the expensive filtering operation<br>  const filteredProducts = useMemo(() =&gt; {<br>    console.log(&#39;Filtering products...&#39;);<br>    return products.filter(product =&gt; <br>      product.name.toLowerCase().includes(filter.toLowerCase())<br>    );<br>  }, [products, filter]);</pre><pre>  return (<br>    &lt;div&gt;<br>      &lt;input <br>        value={filter} <br>        onChange={(e) =&gt; setFilter(e.target.value)}<br>        placeholder=&quot;Search products...&quot;<br>      /&gt;<br>      {filteredProducts.map(product =&gt; (<br>        &lt;div key={product.id}&gt;{product.name}&lt;/div&gt;<br>      ))}<br>    &lt;/div&gt;<br>  );<br>}</pre><h3>useCallback: For Caching Functions</h3><p>The <strong>useCallback</strong> hook caches a <strong><em>function reference</em></strong>. This is useful when you pass functions to child components and want to avoid unnecessary re-renders.</p><h3>Syntax</h3><pre>const memoizedCallback = useCallback(() =&gt; { <br>  doSomething(a, b); <br>}, [a, b]);</pre><h3>Use Cases</h3><ul><li><strong>Passing callbacks</strong>: When passing callbacks to child components</li><li><strong>Event handlers</strong>: Event handlers with memoized components</li><li><strong>Dependency arrays</strong>: Functions in useEffect or useMemo dependencies</li><li><strong>Custom hooks</strong>: Returning stable function references</li></ul><h3>Example</h3><pre>import { useCallback, useState, memo } from &#39;react&#39;;</pre><pre>// Wrap child component with memo<br>const Button = memo(({ onClick, children }) =&gt; {<br>  console.log(&#39;Button rendered:&#39;, children);<br>  return &lt;button onClick={onClick}&gt;{children}&lt;/button&gt;;<br>});</pre><pre>function Parent() {<br>  const [count, setCount] = useState(0);<br>  const [other, setOther] = useState(0);</pre><pre>  // Keep function reference stable<br>  const handleClick = useCallback(() =&gt; {<br>    setCount(c =&gt; c + 1);<br>  }, []); // Empty dependency - function never changes</pre><pre>  return (<br>    &lt;div&gt;<br>      &lt;p&gt;Count: {count}&lt;/p&gt;<br>      &lt;p&gt;Other: {other}&lt;/p&gt;<br>      &lt;Button onClick={handleClick}&gt;Increment Count&lt;/Button&gt;<br>      &lt;button onClick={() =&gt; setOther(o =&gt; o + 1)}&gt;<br>        Increment Other<br>      &lt;/button&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><h3>useMemo vs useCallback: Quick Comparison</h3><p>Aspect useMemo useCallback <strong>Purpose</strong> Caches values Caches functions <strong>Returns</strong> Computed value/result Memoized function <strong>Use Case</strong> Expensive calculations, arrays, objects Event handlers, callbacks to child components <strong>Example</strong> useMemo(() =&gt; a + b, [a, b]) useCallback(() =&gt; fn(a), [a])</p><h3>Key Differences</h3><ol><li><strong>Return Value</strong>: useMemo returns a computed value while useCallback returns a function.</li><li><strong>Execution</strong>: useMemo executes the function and stores the result. useCallback only stores the function reference without executing it.</li><li><strong>Memory</strong>: useMemo caches the value (potentially more memory), useCallback only caches the function definition.</li></ol><h3>Important Note</h3><blockquote><strong><em>useCallback(fn, deps)</em></strong><em> and </em><strong><em>useMemo(() =&gt; fn, deps)</em></strong><em> are technically the same! useCallback is internally a wrapper around useMemo.</em></blockquote><h3>When to Use What?</h3><h3>Use useMemo When:</h3><ul><li>You need to cache the result of an expensive calculation</li><li>You need to filter/transform large arrays or objects</li><li>You need to compute derived state</li><li>You need to maintain reference stability (for objects/arrays)</li></ul><h3>Use useCallback When:</h3><ul><li>You’re passing callbacks to child components (especially memo components)</li><li>You need to use a function in a dependency array (useEffect, useMemo, etc.)</li><li>You want to keep event handlers stable</li><li>You want to return stable function references from custom hooks</li></ul><h3>Common Pitfalls to Avoid</h3><ol><li><strong>Over-optimization</strong>: Using useMemo/useCallback everywhere is wrong. Only use them where there’s actual performance benefit.</li><li><strong>Missing dependencies</strong>: All dependencies must be included in the dependency array, otherwise you’ll get stale closures.</li><li><strong>Premature optimization</strong>: Write code first, measure it, then optimize. Don’t optimize without profiling.</li><li><strong>Complex dependencies</strong>: If your dependency array is very complex, you might need to restructure your component.</li></ol><h3>Best Practices</h3><ul><li><strong>Profile first</strong>: Use React DevTools Profiler to identify actual performance issues</li><li><strong>Use with memo</strong>: useCallback’s value is highest when the child component is wrapped with React.memo</li><li><strong>Keep it simple</strong>: If optimization is getting complex, splitting the component might be a better solution</li><li><strong>ESLint rules</strong>: Use eslint-plugin-react-hooks — it automatically catches dependency array issues</li><li><strong>Document your optimizations</strong>: Write comments explaining why you added the optimization — it helps future developers</li></ul><h3>Conclusion</h3><p><strong>useMemo</strong> and <strong>useCallback</strong> are powerful optimization tools in React, but it’s important to use them wisely. <strong>useMemo</strong> caches values (numbers, arrays, objects), while <strong>useCallback</strong> caches functions.</p><p>Remember: Premature optimization is the root of all evil in programming. First write clear and maintainable code, then identify performance issues (through profiling), and only then optimize where it’s actually needed.</p><p>Happy coding! 🚀</p><p><em>Written with ❤️ for React developers</em></p><p><em>Follow for more React tips and tricks! </em><strong><em>mirbasit01</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1f5741bfc86b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Abdul Basit — Frontend & Blockchain Developer]]></title>
            <link>https://medium.com/@mirbasit01/abdul-basit-frontend-blockchain-developer-83b8f701ddd4?source=rss-a70f08a1a761------2</link>
            <guid isPermaLink="false">https://medium.com/p/83b8f701ddd4</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[backend-development]]></category>
            <category><![CDATA[front-end-development]]></category>
            <dc:creator><![CDATA[mirbasit01]]></dc:creator>
            <pubDate>Sat, 03 Jan 2026 19:24:38 GMT</pubDate>
            <atom:updated>2026-01-19T13:15:32.457Z</atom:updated>
            <content:encoded><![CDATA[<h3>mirbasit01</h3><h3>Abdul Basit Frontend &amp; Blockchain Developer</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/362/1*jjjbu1gMHOc-hAtB69QTVQ.png" /></figure><h3>Hey there, I’m Mir Basit!</h3><p>I’m a <strong>passionate Frontend &amp; Blockchain Developer</strong> who loves building modern and responsive web applications with a strong focus on <strong>performance, scalability, and user experience</strong>.</p><p>I specialize in <strong>React.js, Next.js, and Web3 technologies</strong>, integrating smart contracts and creating decentralized applications (dApps). Currently working at <strong>Quecko Inc, Islamabad</strong> as a Frontend &amp; Blockchain Developer, while simultaneously expanding my skillset by <strong>self-learning backend development</strong> to become a more well-rounded developer.</p><h3>My Tech Arsenal</h3><h3>Frontend Mastery</h3><p>I live and breathe modern frontend development. Here’s what I work with daily:</p><ul><li><strong>React.js &amp; Next.js</strong> — Building lightning-fast, SEO-friendly web applications</li><li><strong>TypeScript &amp; JavaScript ES6+</strong> — Writing type-safe, maintainable code</li><li><strong>Tailwind CSS &amp; Bootstrap 5</strong> — Crafting beautiful, responsive interfaces</li><li><strong>Styled Components</strong> — Creating dynamic, component-scoped styles</li><li><strong>Redux, Context API &amp; Zustand</strong> — Managing complex application state</li><li><strong>Responsive Web Design</strong> — Ensuring pixel-perfect experiences across all devices</li></ul><h3>Web3 &amp; Blockchain</h3><p>The decentralized future excites me, and I’m actively building in this space:</p><ul><li><strong>Wagmi Integration</strong> — Seamless React hooks for Ethereum</li><li><strong>Ethers.js &amp; Web3.js</strong> — Interacting with smart contracts and blockchain networks</li><li><strong>Smart Contract Integration</strong> — Bridging frontend applications with blockchain logic</li><li><strong>dApp Development</strong> — Building decentralized applications from scratch</li><li><strong>Blockchain Solutions</strong> — Creating innovative Web3 experiences</li><li><strong>Wallet Connectivity</strong> — Implementing MetaMask, WalletConnect, and more</li></ul><h3>Backend Development (Currently Learning)</h3><p>Constantly evolving and expanding my skillset:</p><ul><li><strong>Node.js &amp; Express.js</strong> — Building RESTful APIs and server-side logic</li><li><strong>NestJS Framework</strong> — Crafting scalable, enterprise-grade backend systems</li><li><strong>MongoDB Database</strong> — Designing flexible, document-based data models</li><li><strong>RESTful APIs &amp; GraphQL</strong> — Creating efficient data communication layers</li><li><strong>API Integration</strong> — Connecting various services and third-party platforms</li><li><strong>Authentication &amp; Security</strong> — Implementing JWT, OAuth, and secure practices</li></ul><h3>What I Love to Work On</h3><h3>Interactive &amp; Dynamic User Interfaces</h3><p>There’s something magical about bringing designs to life with smooth animations, intuitive interactions, and delightful user experiences. I believe great UI is invisible — it just works.</p><h3>API Integration &amp; State Management</h3><p>Complex data flows don’t scare me; they excite me. Whether it’s integrating third-party APIs, managing global state, or optimizing data fetching strategies, I love solving these architectural challenges.</p><h3>Responsive Web Design &amp; Performance Optimization</h3><p>Every millisecond matters. I’m obsessed with creating blazing-fast applications that work flawlessly on any device, from mobile phones to 4K displays.</p><h3>Web3 dApps &amp; Smart Contract Integration</h3><p>The blockchain revolution is here, and I’m building at the frontier. From NFT marketplaces to DeFi platforms, I’m passionate about creating decentralized solutions that empower users.</p><h3>My Current Journey</h3><p>At <strong>Quecko Inc</strong>, I work as a <strong>Frontend &amp; Blockchain Developer</strong>, building cutting-edge web applications and integrating blockchain solutions for real-world use cases.</p><p>Beyond my day job, I’m passionate about continuous growth. I’m currently <strong>self-learning backend development</strong> — diving deep into Node.js, Express.js, NestJS, and MongoDB to enhance my skillset and evolve into a complete full-stack developer.</p><p>This self-driven learning journey helps me understand the full development lifecycle and build better, more scalable applications. I believe that understanding both frontend and backend makes me a better developer overall.</p><p><strong>Current Role:</strong> Frontend | Blockchain Developer at Quecko Inc, Islamabad</p><p><strong>Self-Learning:</strong> Backend Development (Node.js, Express, NestJS, MongoDB)</p><h3>My Development Philosophy</h3><h3>Quality Over Speed</h3><p>I believe in writing clean, maintainable code that stands the test of time. Quick hacks might work today, but thoughtful architecture works forever.</p><h3>User-Centric Approach</h3><p>Every line of code I write has a user on the other end. Their experience, their needs, and their delight drive my development decisions.</p><h3>Continuous Learning</h3><p>Technology evolves rapidly, and so do I. Whether it’s a new framework, a design pattern, or a programming paradigm, I’m always learning and growing.</p><h3>Community &amp; Collaboration</h3><p>I believe in giving back to the developer community. Whether through open-source contributions, helping other developers, or sharing knowledge, we grow together.</p><h3>Let’s Connect!</h3><p>I’m always excited to connect with fellow developers, potential collaborators, or anyone interested in tech!</p><p><strong>🌐 Portfolio:</strong> <a href="https://iamabdulbasit.netlify.app/">iamabdulbasit.netlify.app</a></p><p><strong>💻 GitHub:</strong> <a href="https://github.com/mirbasit01">@mirbasit01</a></p><p><strong>💼 LinkedIn:</strong> <a href="https://linkedin.com/in/abdul-basit-17a689234">abdul-basit-17a689234</a></p><p><strong>𝕏 Twitter/X:</strong> <a href="https://x.com/iamabdulbasit__">@iamabdulbasit__</a></p><p><strong>📸 Instagram:</strong> @mirbasit01_</p><p><strong>👤 Facebook:</strong> <a href="https://facebook.com/profile.php?id=61581397951321">Abdul Basit</a></p><p><strong>🧩 LeetCode:</strong> <a href="https://leetcode.com/u/mirbasit01">@mirbasit01</a></p><h3>Let’s Build Something Amazing Together</h3><p>Whether you’re:</p><ul><li>Working on a cutting-edge web application</li><li>Need Web3/dApp development expertise</li><li>Looking for frontend development services</li><li>Seeking a collaborator for an innovative project</li></ul><p><strong>I’d love to hear from you!</strong></p><p>I’m currently open for: Freelance Projects : Full-time Opportunities : Technical Collaborations : Open Source Contributions</p><h3>Get In Touch</h3><p>Feel free to reach out through any of my social channels above. I typically respond within 24 hours and I’m always happy to chat about:</p><ul><li><strong>Web Development</strong> — Frontend, Backend, or Full Stack</li><li><strong>Blockchain &amp; Web3</strong> — Smart contracts, dApps, and decentralized solutions</li><li><strong>Tech Career Advice</strong> — Happy to help fellow developers on their journey</li><li><strong>Project Collaboration</strong> — Let’s build something amazing together!</li></ul><p><strong>© 2023 Abdul Basit • Frontend &amp; Blockchain Developer • Islamabad, Pakistan</strong></p><p><em>Crafted with passion, precision &amp; code</em></p><h3>Tags</h3><p>#WebDevelopment #ReactJS #NextJS #Web3 #Blockchain #Frontend #Developer #Programming #JavaScript #TypeScript #dApps #SmartContracts #TechCareer #SoftwareEngineering #FullStack</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=83b8f701ddd4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Node.js Express MongoDB backend API setup]]></title>
            <link>https://medium.com/@mirbasit01/node-js-express-mongodb-backend-api-setup-1b152769697e?source=rss-a70f08a1a761------2</link>
            <guid isPermaLink="false">https://medium.com/p/1b152769697e</guid>
            <category><![CDATA[expressjs]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[backend]]></category>
            <category><![CDATA[mongodb]]></category>
            <category><![CDATA[node-js-development]]></category>
            <dc:creator><![CDATA[mirbasit01]]></dc:creator>
            <pubDate>Thu, 01 Jan 2026 19:45:23 GMT</pubDate>
            <atom:updated>2026-01-01T20:03:38.527Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*AB5NMbj0ODcoISKJAt9uPg.png" /></figure><h3>Node.js Express MongoDB Quick Reference Guide</h3><h3>Quick Start Commands</h3><pre># Initialize project<br>npm init -y</pre><pre># Install dependencies<br>npm install express mongoose</pre><pre># Start MongoDB (Mac/Linux)<br>mongod</pre><pre># Run server<br>node index.js</pre><h3>📦 Essential Imports</h3><pre>const express = require(&#39;express&#39;);<br>const mongoose = require(&#39;mongoose&#39;);<br>const fs = require(&#39;fs&#39;);</pre><h3>🔌 MongoDB Connection</h3><pre>mongoose.connect(&#39;mongodb://127.0.0.1:27017/nodeWebServer&#39;)<br>  .then(() =&gt; console.log(&#39;MongoDB Connected&#39;))<br>  .catch(err =&gt; console.log(&#39;Error:&#39;, err));</pre><h3>📊 Schema Definition</h3><pre>const userSchema = new mongoose.Schema({<br>  firstName: { type: String, required: true },<br>  lastName: String,<br>  email: { type: String, required: true, unique: true },<br>  jobTitle: String,<br>  gender: String<br>}, { timestamps: true });</pre><pre>const User = mongoose.model(&#39;user&#39;, userSchema);</pre><h3>⚙️ Middleware Setup</h3><pre>// Body parsers<br>app.use(express.urlencoded({ extended: false }));<br>app.use(express.json());</pre><pre>// Custom logging<br>app.use((req, res, next) =&gt; {<br>  const log = `${new Date().toISOString()} - ${req.ip} ${req.method} - ${req.path}\n`;<br>  fs.appendFile(&#39;access.log&#39;, log, (err) =&gt; {<br>    if (err) console.error(&#39;Logging error:&#39;, err);<br>  });<br>  next();<br>});</pre><h3>📡 API Endpoints Cheat Sheet</h3><h3>GET All Users (HTML)</h3><pre>app.get(&#39;/users&#39;, async (req, res) =&gt; {<br>  const allUsers = await User.find({});<br>  const html = `&lt;ul&gt;${allUsers.map(user =&gt; `&lt;li&gt;${user.firstName} - ${user.email}&lt;/li&gt;`).join(&#39;&#39;)}&lt;/ul&gt;`;<br>  res.send(html);<br>});</pre><h3>GET All Users (JSON)</h3><pre>app.get(&#39;/api/users&#39;, async (req, res) =&gt; {<br>  const allUsers = await User.find({});<br>  res.json(allUsers);<br>});</pre><h3>GET Single User</h3><pre>app.get(&#39;/api/users/:id&#39;, async (req, res) =&gt; {<br>  const user = await User.findById(req.params.id);<br>  if (!user) return res.status(404).json({ error: &#39;User not found&#39; });<br>  res.json(user);<br>});</pre><h3>POST Create User</h3><pre>app.post(&#39;/api/users&#39;, async (req, res) =&gt; {<br>  const body = req.body;<br>  <br>  if (!body.first_name || !body.email) {<br>    return res.status(400).json({ error: &#39;First name and email required&#39; });<br>  }</pre><pre>  const result = await User.create({<br>    firstName: body.first_name,<br>    lastName: body.last_name,<br>    email: body.email,<br>    gender: body.gender,<br>    jobTitle: body.job_title<br>  });</pre><pre>  res.status(201).json({ message: &#39;Success&#39;, user: result });<br>});</pre><h3>PATCH Update User</h3><pre>app.patch(&#39;/api/users/:id&#39;, async (req, res) =&gt; {<br>  await User.findByIdAndUpdate(req.params.id, req.body);<br>  res.json({ message: &#39;User updated successfully&#39; });<br>});</pre><h3>DELETE User</h3><pre>app.delete(&#39;/api/users/:id&#39;, async (req, res) =&gt; {<br>  await User.findByIdAndDelete(req.params.id);<br>  res.json({ message: &#39;User deleted successfully&#39; });<br>});</pre><h3>🌐 Server Startup</h3><pre>const PORT = 3000;<br>app.listen(PORT, () =&gt; {<br>  console.log(`Server running on http://localhost:${PORT}`);<br>});</pre><h3>🧪 Testing with cURL</h3><pre># Get all users<br>curl http://localhost:3000/api/users</pre><pre># Create user<br>curl -X POST <a href="http://localhost:3000/api/users">http://localhost:3000/api/users</a> \<br>  -H &quot;Content-Type: application/json&quot; \<br>  -d &#39;{&quot;first_name&quot;:&quot;John&quot;,&quot;last_name&quot;:&quot;Doe&quot;,&quot;email&quot;:&quot;john@example.com&quot;,&quot;gender&quot;:&quot;Male&quot;,&quot;job_title&quot;:&quot;Developer&quot;}&#39;</pre><pre># Get single user<br>curl http://localhost:3000/api/users/&lt;USER_ID&gt;</pre><pre># Update user<br>curl -X PATCH http://localhost:3000/api/users/&lt;USER_ID&gt; \<br>  -H &quot;Content-Type: application/json&quot; \<br>  -d &#39;{&quot;jobTitle&quot;:&quot;Senior Developer&quot;}&#39;</pre><pre># Delete user<br>curl -X DELETE http://localhost:3000/api/users/&lt;USER_ID&gt;</pre><h3>🔍 Mongoose Query Methods</h3><pre>// Find all<br>User.find({})</pre><pre>// Find by ID<br>User.findById(id)</pre><pre>// Find one by criteria<br>User.findOne({ email: &#39;john@example.com&#39; })</pre><pre>// Create<br>User.create({ firstName: &#39;John&#39;, email: &#39;john@example.com&#39; })</pre><pre>// Update by ID<br>User.findByIdAndUpdate(id, { firstName: &#39;Jane&#39; })</pre><pre>// Delete by ID<br>User.findByIdAndDelete(id)</pre><pre>// Count documents<br>User.countDocuments({})</pre><h3>⚡ Common Patterns</h3><h3>Error Handling</h3><pre>app.get(&#39;/api/users&#39;, async (req, res) =&gt; {<br>  try {<br>    const users = await User.find({});<br>    res.json(users);<br>  } catch (error) {<br>    res.status(500).json({ error: error.message });<br>  }<br>});</pre><h3>Validation</h3><pre>if (!req.body.email) {<br>  return res.status(400).json({ error: &#39;Email is required&#39; });<br>}</pre><h3>Response Status Codes</h3><pre>res.status(200).json({ data });     // OK<br>res.status(201).json({ data });     // Created<br>res.status(400).json({ error });    // Bad Request<br>res.status(404).json({ error });    // Not Found<br>res.status(500).json({ error });    // Server Error</pre><h3>📝 HTTP Status Codes Reference</h3><p>Code Meaning Usage 200 OK Successful GET, PATCH, DELETE 201 Created Successful POST (resource created) 400 Bad Request Invalid request data 404 Not Found Resource doesn’t exist 500 Internal Server Error Server-side error</p><h3>🛠️ Useful npm Scripts</h3><p>Add to package.json:</p><pre>{<br>  &quot;scripts&quot;: {<br>    &quot;start&quot;: &quot;node index.js&quot;,<br>    &quot;dev&quot;: &quot;nodemon index.js&quot;<br>  }<br>}</pre><p>Then install nodemon for auto-restart:</p><pre>npm install --save-dev nodemon<br>npm run dev</pre><h3>🔐 Environment Variables (Production)</h3><pre>// Install dotenv<br>npm install dotenv</pre><pre>// .env file<br>PORT=3000<br>MONGODB_URI=mongodb://127.0.0.1:27017/nodeWebServer</pre><pre>// index.js<br>require(&#39;dotenv&#39;).config();<br>const PORT = process.env.PORT || 3000;<br>mongoose.connect(process.env.MONGODB_URI);</pre><h3>📦 Project Structure (Advanced)</h3><pre>node-web-server/<br>├── config/<br>│   └── database.js<br>├── controllers/<br>│   └── userController.js<br>├── models/<br>│   └── User.js<br>├── routes/<br>│   └── userRoutes.js<br>├── middleware/<br>│   └── logger.js<br>├── .env<br>├── index.js<br>└── package.json</pre><h3>🚀 Deployment Checklist</h3><ul><li>[ ] Use environment variables</li><li>[ ] Add error handling middleware</li><li>[ ] Implement input validation</li><li>[ ] Add authentication (JWT)</li><li>[ ] Use HTTPS</li><li>[ ] Set up CORS</li><li>[ ] Add rate limiting</li><li>[ ] Enable compression</li><li>[ ] Set security headers (helmet)</li><li>[ ] Add logging (winston/morgan)</li><li>[ ] Set up monitoring</li><li>[ ] Create API documentation</li></ul><h3>💡 Tips &amp; Best Practices</h3><ol><li><strong>Always use async/await</strong> for database operations</li><li><strong>Never expose sensitive data</strong> in error messages</li><li><strong>Validate input</strong> before processing</li><li><strong>Use appropriate status codes</strong></li><li><strong>Log all errors</strong> for debugging</li><li><strong>Keep routes organized</strong> in separate files</li><li><strong>Use environment variables</strong> for configuration</li><li><strong>Add comments</strong> to complex code</li><li><strong>Test your APIs</strong> thoroughly</li><li><strong>Keep dependencies updated</strong></li></ol><p><strong>Quick Links:</strong></p><ul><li><a href="https://github.com/mirbasit01/nodeWebServer">GitHub Repository</a></li><li><a href="https://expressjs.com/">Express Docs</a></li><li><a href="https://mongoosejs.com/">Mongoose Docs</a></li><li><a href="https://docs.mongodb.com/">MongoDB Docs</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1b152769697e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>