<?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"><channel><title><![CDATA[Frontend ki baat cheet]]></title><description><![CDATA[Frontend ki baat cheet]]></description><link>https://frontend-baat-cheet.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Thu, 18 Jun 2026 06:51:06 GMT</lastBuildDate><atom:link href="https://frontend-baat-cheet.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[React Performance Optimization]]></title><description><![CDATA[React Performance Optimization : Deep Dive into React.memo, useMemo, useCallback & Lazy Loading
When building scalable React apps, performance becomes critical.
React gives us powerful tools to:

Prev]]></description><link>https://frontend-baat-cheet.hashnode.dev/react-performance-optimization</link><guid isPermaLink="true">https://frontend-baat-cheet.hashnode.dev/react-performance-optimization</guid><dc:creator><![CDATA[paras jain]]></dc:creator><pubDate>Tue, 31 Mar 2026 06:31:29 GMT</pubDate><content:encoded><![CDATA[<p>React Performance Optimization : Deep Dive into <code>React.memo</code>, <code>useMemo</code>, <code>useCallback</code> &amp; Lazy Loading</p>
<p>When building scalable React apps, performance becomes critical.</p>
<p>React gives us powerful tools to:</p>
<ul>
<li><p>Prevent unnecessary re-renders</p>
</li>
<li><p>Avoid expensive recalculations</p>
</li>
<li><p>Reduce bundle size</p>
</li>
</ul>
<p>Let’s break them down deeply 👇</p>
<hr />
<h1>🧠 1. <code>React.memo</code> — Component Memoization</h1>
<h2>📌 What is it?</h2>
<p><code>React.memo</code> is a <strong>Higher Order Component (HOC)</strong> that prevents re-rendering of a component <strong>if props haven’t changed</strong>.</p>
<hr />
<h2>🔍 How React Normally Works</h2>
<p>Whenever a parent re-renders: 👉 All child components re-render by default</p>
<p>Even if props are the same 😬</p>
<hr />
<h2>✅ Solution</h2>
<pre><code class="language-jsx">const Child = React.memo(({ name }) =&gt; {
  console.log("Child Rendered");
  return &lt;h1&gt;{name}&lt;/h1&gt;;
});
</code></pre>
<hr />
<h2>⚙️ Under the Hood</h2>
<ul>
<li><p>Performs <strong>shallow comparison</strong> of props</p>
</li>
<li><p>If props unchanged → skips render</p>
</li>
</ul>
<hr />
<h2>⚠️ Important Gotcha</h2>
<pre><code class="language-jsx">&lt;Child user={{ name: "Paras" }} /&gt;
</code></pre>
<p>❌ This will re-render every time Why? → New object reference on every render</p>
<hr />
<h2>✅ Fix</h2>
<pre><code class="language-jsx">const user = useMemo(() =&gt; ({ name: "Paras" }), []);
&lt;Child user={user} /&gt;
</code></pre>
<hr />
<h2>🔥 When to Use</h2>
<p>✔ Pure functional components ✔ Expensive UI rendering ✔ Large lists / tables</p>
<hr />
<h2>❌ When NOT to Use</h2>
<p>❌ Small/simple components ❌ Props change frequently</p>
<hr />
<h1>🧠 2. <code>useMemo</code> — Value Memoization</h1>
<h2>📌 What is it?</h2>
<p>Caches the result of a <strong>computed value</strong> and recalculates only when dependencies change.</p>
<hr />
<h2>🧠 Syntax</h2>
<pre><code class="language-jsx">const memoizedValue = useMemo(() =&gt; computeFn(), [deps]);
</code></pre>
<hr />
<h2>🔥 Example</h2>
<pre><code class="language-jsx">const sortedList = useMemo(() =&gt; {
  console.log("Sorting...");
  return items.sort((a, b) =&gt; a.price - b.price);
}, [items]);
</code></pre>
<hr />
<h2>⚠️ Without <code>useMemo</code></h2>
<ul>
<li><p>Sorting runs on every render</p>
</li>
<li><p>Bad for large datasets</p>
</li>
</ul>
<hr />
<h2>💡 Real Use Cases</h2>
<ul>
<li><p>Sorting / filtering lists</p>
</li>
<li><p>Expensive calculations</p>
</li>
<li><p>Derived state</p>
</li>
</ul>
<hr />
<h2>⚠️ Common Mistake</h2>
<pre><code class="language-jsx">const value = useMemo(() =&gt; num * 2, []);
</code></pre>
<p>❌ Missing dependency → stale value bug</p>
<hr />
<h2>🧠 Rule</h2>
<p>👉 Always include all dependencies</p>
<hr />
<h1>🧠 3. <code>useCallback</code> — Function Memoization</h1>
<h2>📌 What is it?</h2>
<p>Returns a <strong>memoized function</strong> (same reference unless dependencies change)</p>
<hr />
<h2>🧠 Syntax</h2>
<pre><code class="language-jsx">const memoizedFn = useCallback(() =&gt; {}, [deps]);
</code></pre>
<hr />
<h2>🔥 Problem Without It</h2>
<pre><code class="language-jsx">const handleClick = () =&gt; {};
</code></pre>
<p>👉 New function created every render 👉 Causes child re-renders</p>
<hr />
<h2>✅ With <code>useCallback</code></h2>
<pre><code class="language-jsx">const handleClick = useCallback(() =&gt; {
  console.log("Clicked");
}, []);
</code></pre>
<hr />
<h2>🔗 Real Use Case (Important)</h2>
<pre><code class="language-jsx">const Child = React.memo(({ onClick }) =&gt; {
  console.log("Child rendered");
  return &lt;button onClick={onClick}&gt;Click&lt;/button&gt;;
});

const Parent = () =&gt; {
  const handleClick = useCallback(() =&gt; {
    console.log("Clicked");
  }, []);

  return &lt;Child onClick={handleClick} /&gt;;
};
</code></pre>
<p>✔ Child will NOT re-render unnecessarily</p>
<hr />
<h2>⚠️ Important Insight</h2>
<p>👉 <code>useCallback</code> is mainly useful with:</p>
<ul>
<li><p><code>React.memo</code></p>
</li>
<li><p>Dependency arrays</p>
</li>
</ul>
<hr />
<h1>🔁 <code>useMemo</code> vs <code>useCallback</code></h1>
<table>
<thead>
<tr>
<th>Feature</th>
<th>useMemo</th>
<th>useCallback</th>
</tr>
</thead>
<tbody><tr>
<td>Returns</td>
<td>Value</td>
<td>Function</td>
</tr>
<tr>
<td>Use case</td>
<td>Expensive computation</td>
<td>Stable function reference</td>
</tr>
<tr>
<td>Internally</td>
<td>Runs function</td>
<td>Returns function</td>
</tr>
</tbody></table>
<hr />
<h1>🚀 4. Lazy Loading &amp; Code Splitting</h1>
<h2>📌 Problem</h2>
<p>React apps bundle everything into one file → large bundle size → slow initial load</p>
<hr />
<h2>✅ Solution: Code Splitting</h2>
<p>Load components <strong>only when needed</strong></p>
<hr />
<h2>🔹 <code>React.lazy</code></h2>
<pre><code class="language-jsx">const Dashboard = React.lazy(() =&gt; import("./Dashboard"));
</code></pre>
<hr />
<h2>🔹 <code>Suspense</code></h2>
<pre><code class="language-jsx">&lt;Suspense fallback={&lt;h2&gt;Loading...&lt;/h2&gt;}&gt;
  &lt;Dashboard /&gt;
&lt;/Suspense&gt;
</code></pre>
<hr />
<h2>🧠 What Happens?</h2>
<ol>
<li><p>Component is NOT loaded initially</p>
</li>
<li><p>When needed → dynamically imported</p>
</li>
<li><p>Fallback UI shown while loading</p>
</li>
</ol>
<hr />
<h2>🔥 Best Use Cases</h2>
<ul>
<li><p>Route-based splitting (React Router)</p>
</li>
<li><p>Heavy components (charts, dashboards)</p>
</li>
<li><p>Admin panels</p>
</li>
</ul>
<hr />
<h2>⚠️ Limitation</h2>
<p>❌ Works only with default exports</p>
<hr />
<h2>✅ Fix</h2>
<pre><code class="language-jsx">const Dashboard = React.lazy(() =&gt;
  import("./Dashboard").then(module =&gt; ({ default: module.Dashboard }))
);
</code></pre>
<hr />
<h1>⚡ Combining Everything (Real-World Pattern)</h1>
<pre><code class="language-jsx">const List = React.memo(({ items, onSelect }) =&gt; {
  console.log("List rendered");
  return items.map(item =&gt; (
    &lt;div key={item.id} onClick={() =&gt; onSelect(item)}&gt;
      {item.name}
    &lt;/div&gt;
  ));
});

function App({ data }) {
  const sortedData = useMemo(() =&gt; {
    return data.sort((a, b) =&gt; a.name.localeCompare(b.name));
  }, [data]);

  const handleSelect = useCallback((item) =&gt; {
    console.log(item);
  }, []);

  return &lt;List items={sortedData} onSelect={handleSelect} /&gt;;
}
</code></pre>
<hr />
<h1>⚠️ Over-Optimization Trap (VERY IMPORTANT)</h1>
<p>Most beginners do this:</p>
<pre><code class="language-jsx">useMemo(() =&gt; value, []);
useCallback(() =&gt; {}, []);
React.memo(Component);
</code></pre>
<p>❌ Everywhere.</p>
<hr />
<h2>🧠 Reality:</h2>
<p>These hooks also have a cost:</p>
<ul>
<li><p>Memory overhead</p>
</li>
<li><p>Comparison cost</p>
</li>
</ul>
<hr />
<h2>✅ Rule of Thumb</h2>
<p>👉 Use only when:</p>
<ul>
<li><p>Re-render is actually expensive</p>
</li>
<li><p>You see performance issues</p>
</li>
<li><p>Profiling shows bottlenecks</p>
</li>
</ul>
<hr />
<h1>🧪 How to Decide? (Pro Tip)</h1>
<p>Use <strong>React DevTools Profiler</strong></p>
<p>👉 Check:</p>
<ul>
<li><p>Which component re-renders</p>
</li>
<li><p>How often</p>
</li>
<li><p>How long it takes</p>
</li>
</ul>
<hr />
<h1>🧠 Final Mental Model</h1>
<table>
<thead>
<tr>
<th>Tool</th>
<th>Think Like</th>
</tr>
</thead>
<tbody><tr>
<td>React.memo</td>
<td>"Skip re-render if same props"</td>
</tr>
<tr>
<td>useMemo</td>
<td>"Cache computed value"</td>
</tr>
<tr>
<td>useCallback</td>
<td>"Cache function reference"</td>
</tr>
<tr>
<td>React.lazy</td>
<td>"Load component later"</td>
</tr>
</tbody></table>
<hr />
<h1>🏁 Conclusion</h1>
<p>React performance optimization is not about using all tools everywhere — it’s about <strong>using the right tool at the right place</strong>.</p>
<blockquote>
<p>First make it work. Then make it fast. 🚀</p>
</blockquote>
]]></content:encoded></item><item><title><![CDATA[Project Setup - Webpack]]></title><description><![CDATA[Create Project Folder


First create a clean project.
mkdir ecommerce-webpack
cd ecommerce-webpack

Now initialize npm.
npm init -y

This creates:
package.json

Why?
package.json manages:

dependencie]]></description><link>https://frontend-baat-cheet.hashnode.dev/project-setup-webpack</link><guid isPermaLink="true">https://frontend-baat-cheet.hashnode.dev/project-setup-webpack</guid><dc:creator><![CDATA[paras jain]]></dc:creator><pubDate>Sat, 07 Mar 2026 12:29:28 GMT</pubDate><content:encoded><![CDATA[<ul>
<li><h2>Create Project Folder</h2>
</li>
</ul>
<p>First create a clean project.</p>
<pre><code class="language-plaintext">mkdir ecommerce-webpack
cd ecommerce-webpack
</code></pre>
<p>Now initialize npm.</p>
<pre><code class="language-plaintext">npm init -y
</code></pre>
<p>This creates:</p>
<pre><code class="language-plaintext">package.json
</code></pre>
<h3>Why?</h3>
<p><code>package.json</code> manages:</p>
<ul>
<li><p>dependencies</p>
</li>
<li><p>scripts</p>
</li>
<li><p>project metadata</p>
</li>
</ul>
<p>Example later:</p>
<pre><code class="language-plaintext">npm run dev
npm run build
</code></pre>
<hr />
<ul>
<li><h2>Install Core Dependencies</h2>
</li>
</ul>
<p>Now install <strong>Webpack + loaders + tools</strong>.</p>
<pre><code class="language-plaintext">npm install --save-dev \
webpack \
webpack-cli \
webpack-dev-server \
html-webpack-plugin \
mini-css-extract-plugin \
css-loader \
sass \
sass-loader \
style-loader \
handlebars \
handlebars-loader \
babel-loader \
@babel/core \
@babel/preset-env \
clean-webpack-plugin
</code></pre>
<h3>What these do</h3>
<table>
<thead>
<tr>
<th>Package</th>
<th>Purpose</th>
</tr>
</thead>
<tbody><tr>
<td>webpack</td>
<td>bundler</td>
</tr>
<tr>
<td>webpack-cli</td>
<td>run webpack from terminal</td>
</tr>
<tr>
<td>webpack-dev-server</td>
<td>local development server</td>
</tr>
<tr>
<td>html-webpack-plugin</td>
<td>auto generate HTML</td>
</tr>
<tr>
<td>mini-css-extract-plugin</td>
<td>extract css into files</td>
</tr>
<tr>
<td>sass</td>
<td>SCSS compiler</td>
</tr>
<tr>
<td>sass-loader</td>
<td>lets webpack compile SCSS</td>
</tr>
<tr>
<td>css-loader</td>
<td>import css in JS</td>
</tr>
<tr>
<td>style-loader</td>
<td>inject css to DOM</td>
</tr>
<tr>
<td>handlebars</td>
<td>template engine</td>
</tr>
<tr>
<td>handlebars-loader</td>
<td>compile handlebars</td>
</tr>
<tr>
<td>babel-loader</td>
<td>convert ES6 to browser compatible JS</td>
</tr>
<tr>
<td>clean-webpack-plugin</td>
<td>cleans dist folder</td>
</tr>
</tbody></table>
<hr />
<ul>
<li><h2>Install Bootstrap</h2>
</li>
</ul>
<pre><code class="language-plaintext">npm install bootstrap
</code></pre>
<p>We will import only SCSS parts.</p>
<hr />
<ul>
<li><h2>Install Husky</h2>
</li>
</ul>
<p>Husky helps enforce <strong>clean commits</strong>.</p>
<pre><code class="language-plaintext">npm install husky --save-dev
</code></pre>
<p>Enable husky:</p>
<pre><code class="language-plaintext">npx husky install
</code></pre>
<p>Add prepare script.</p>
<p>Open <strong>package.json</strong></p>
<pre><code class="language-plaintext">"scripts": {
  "prepare": "husky install"
}
</code></pre>
<hr />
<ul>
<li><h2>Create Folder Structure</h2>
</li>
</ul>
<p>Create folder structure, example:</p>
<pre><code class="language-plaintext">ecommerce-webpack
│
├── src
│   ├── assets
│   │   ├── images
│   │   └── icons
│   │
│   ├── js
│   │   ├── api
│   │   ├── components
│   │   ├── pages
│   │   └── utils
│   │
│   ├── scss
│   │   ├── base
│   │   ├── components
│   │   ├── layout
│   │   └── main.scss
│   │
│   ├── templates
│   │   ├── components
│   │   └── pages
│   │
│   ├── index.html
│   └── index.js
│
├── webpack
│   ├── webpack.dev.js
│   └── webpack.prod.js
│
├── dist
└── package.json
</code></pre>
<h3>Why this structure?</h3>
<table>
<thead>
<tr>
<th>Folder</th>
<th>Purpose</th>
</tr>
</thead>
<tbody><tr>
<td>assets</td>
<td>images/icons</td>
</tr>
<tr>
<td>js</td>
<td>all JS logic</td>
</tr>
<tr>
<td>scss</td>
<td>styles</td>
</tr>
<tr>
<td>templates</td>
<td>handlebars</td>
</tr>
<tr>
<td>pages</td>
<td>page specific code</td>
</tr>
<tr>
<td>components</td>
<td>reusable UI</td>
</tr>
</tbody></table>
<p>This matches <strong>industry frontend architecture</strong>.</p>
<hr />
<ul>
<li><h2>Create Entry File</h2>
</li>
</ul>
<p>Create:</p>
<pre><code class="language-plaintext">src/index.js
</code></pre>
<p>Example:</p>
<pre><code class="language-plaintext">import './scss/main.scss'

console.log("App started")
</code></pre>
<hr />
<ul>
<li><h2>Create Base HTML</h2>
</li>
</ul>
<p>Create:</p>
<pre><code class="language-plaintext">src/index.html
</code></pre>
<p>Example:</p>
<pre><code class="language-plaintext">&lt;!DOCTYPE html&gt;
&lt;html lang="en"&gt;
&lt;head&gt;
  &lt;meta charset="UTF-8"&gt;
  &lt;title&gt;E-Commerce&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;

  &lt;div id="app"&gt;&lt;/div&gt;

&lt;/body&gt;
&lt;/html&gt;
</code></pre>
<p>Webpack will inject JS automatically.</p>
<hr />
<ul>
<li><h2>Setup SCSS Entry</h2>
</li>
</ul>
<p>Create:</p>
<pre><code class="language-plaintext">src/scss/main.scss
</code></pre>
<p>Example:</p>
<pre><code class="language-plaintext">@import "bootstrap/scss/bootstrap";

body{
  background:#f8f9fa;
}
</code></pre>
<hr />
<ul>
<li><h2>Create Webpack Dev Config</h2>
</li>
</ul>
<p>Create:</p>
<pre><code class="language-plaintext">webpack/webpack.dev.js
</code></pre>
<p>Example basic config:</p>
<pre><code class="language-plaintext">const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')

module.exports = {
  mode: 'development',

  entry: './src/index.js',

  output: {
    filename: 'bundle.js',
    path: path.resolve(__dirname, '../dist'),
    clean: true
  },

  devServer: {
    static: './dist',
    port: 3000,
    open: true
  },

  module: {
    rules: [
      {
        test: /\.scss$/,
        use: ['style-loader','css-loader','sass-loader']
      },
      {
        test: /\.hbs$/,
        loader: 'handlebars-loader'
      },
      {
        test: /\.js$/,
        exclude: /node_modules/,
        use: 'babel-loader'
      }
    ]
  },

  plugins: [
    new HtmlWebpackPlugin({
      template:'./src/index.html'
    })
  ]
}
</code></pre>
<hr />
<ul>
<li><h2>Babel Config</h2>
</li>
</ul>
<p>Create:</p>
<pre><code class="language-plaintext">.babelrc
</code></pre>
<pre><code class="language-plaintext">{
 "presets": ["@babel/preset-env"]
}
</code></pre>
<hr />
<ul>
<li><h2>Add Scripts</h2>
</li>
</ul>
<p>In <strong>package.json</strong></p>
<pre><code class="language-plaintext">"scripts": {
  "dev": "webpack serve --config webpack/webpack.dev.js",
  "build": "webpack --config webpack/webpack.prod.js"
}
</code></pre>
<hr />
<ul>
<li><h2>Run Project</h2>
</li>
</ul>
<p>Start dev server:</p>
<pre><code class="language-plaintext">npm run dev
</code></pre>
]]></content:encoded></item><item><title><![CDATA[Git & GitHub Branching]]></title><description><![CDATA[If you're starting your developer journey (especially as a student or aspiring MERN stack dev), mastering Git workflow is non-negotiable.
In this guide, I’ll teach you step-by-step how to:

✅ Create a GitHub repository

✅ Create a develop branch

✅ C...]]></description><link>https://frontend-baat-cheet.hashnode.dev/git-and-github-branching</link><guid isPermaLink="true">https://frontend-baat-cheet.hashnode.dev/git-and-github-branching</guid><category><![CDATA[GitHub]]></category><category><![CDATA[Git]]></category><category><![CDATA[Branching Strategies]]></category><dc:creator><![CDATA[paras jain]]></dc:creator><pubDate>Sat, 14 Feb 2026 14:12:18 GMT</pubDate><content:encoded><![CDATA[<p>If you're starting your developer journey (especially as a student or aspiring MERN stack dev), mastering Git workflow is <strong>non-negotiable</strong>.</p>
<p>In this guide, I’ll teach you step-by-step how to:</p>
<ul>
<li><p>✅ Create a GitHub repository</p>
</li>
<li><p>✅ Create a <code>develop</code> branch</p>
</li>
<li><p>✅ Create a <code>feature</code> branch</p>
</li>
<li><p>✅ Commit your changes</p>
</li>
<li><p>✅ Push branches to GitHub</p>
</li>
<li><p>✅ Merge feature → develop</p>
</li>
<li><p>✅ Push updated develop</p>
</li>
<li><p>✅ Merge develop → main</p>
</li>
</ul>
<p>This is a <strong>real-world workflow</strong> used in companies.</p>
<hr />
<h1 id="heading-why-this-workflow">🧠 Why This Workflow?</h1>
<p>Instead of working directly on <code>main</code>, professional teams follow:</p>
<pre><code class="lang-plaintext">main → production-ready code
develop → integration branch
feature/* → individual features
</code></pre>
<p>This keeps code clean and production safe.</p>
<hr />
<h1 id="heading-step-1-create-a-github-repository">🏗 Step 1: Create a GitHub Repository</h1>
<ol>
<li><p>Go to <strong>GitHub</strong></p>
</li>
<li><p>Click <strong>New Repository</strong></p>
</li>
<li><p>Name it (example: <code>inventory-app</code>)</p>
</li>
<li><p>Click <strong>Create repository</strong></p>
</li>
</ol>
<p>Now copy the HTTPS URL.</p>
<p>Example:</p>
<pre><code class="lang-plaintext">https://github.com/yourusername/inventory-app.git
</code></pre>
<hr />
<h1 id="heading-step-2-clone-the-repository">💻 Step 2: Clone the Repository</h1>
<pre><code class="lang-plaintext">git clone https://github.com/yourusername/inventory-app.git
cd inventory-app
</code></pre>
<p>Check branch:</p>
<pre><code class="lang-plaintext">git branch
</code></pre>
<p>By default, you’ll be on:</p>
<pre><code class="lang-plaintext">main
</code></pre>
<hr />
<h1 id="heading-step-3-create-a-develop-branch">🌱 Step 3: Create a <code>develop</code> Branch</h1>
<pre><code class="lang-plaintext">git checkout -b develop
</code></pre>
<p>Push it to GitHub:</p>
<pre><code class="lang-plaintext">git push -u origin develop
</code></pre>
<p>Now your repo has:</p>
<pre><code class="lang-plaintext">main
develop
</code></pre>
<hr />
<h1 id="heading-step-4-create-a-feature-branch">✨ Step 4: Create a Feature Branch</h1>
<p>Let’s say you're building a login feature.</p>
<pre><code class="lang-plaintext">git checkout develop
git checkout -b feature/login
</code></pre>
<p>Now you are working safely inside:</p>
<pre><code class="lang-plaintext">feature/login
</code></pre>
<hr />
<h1 id="heading-step-5-add-amp-commit-changes">📝 Step 5: Add &amp; Commit Changes</h1>
<p>After writing your code:</p>
<pre><code class="lang-plaintext">git add .
git commit -m "feat: add login functionality"
</code></pre>
<p>Pro Tip:<br />Use meaningful commit messages like:</p>
<ul>
<li><p><code>feat:</code> for features</p>
</li>
<li><p><code>fix:</code> for bug fixes</p>
</li>
<li><p><code>refactor:</code> for improvements</p>
</li>
</ul>
<hr />
<h1 id="heading-step-6-push-feature-branch">☁️ Step 6: Push Feature Branch</h1>
<pre><code class="lang-plaintext">git push -u origin feature/login
</code></pre>
<p>Now go to GitHub → You’ll see a <strong>Compare &amp; Pull Request</strong> option.</p>
<hr />
<h1 id="heading-step-7-merge-feature-develop">🔀 Step 7: Merge Feature → Develop</h1>
<h3 id="heading-option-1-using-github-recommended-for-teams">Option 1: Using GitHub (Recommended for Teams)</h3>
<ol>
<li><p>Open Pull Request</p>
</li>
<li><p>Base: <code>develop</code></p>
</li>
<li><p>Compare: <code>feature/login</code></p>
</li>
<li><p>Click <strong>Merge Pull Request</strong></p>
</li>
</ol>
<p>Done ✅</p>
<hr />
<h3 id="heading-option-2-using-terminal">Option 2: Using Terminal</h3>
<pre><code class="lang-plaintext">git checkout develop
git merge feature/login
</code></pre>
<hr />
<h1 id="heading-step-8-push-updated-develop">🚀 Step 8: Push Updated Develop</h1>
<p>After merging locally:</p>
<pre><code class="lang-plaintext">git push origin develop
</code></pre>
<p>Now <code>develop</code> contains your new feature.</p>
<hr />
<h1 id="heading-step-9-merge-develop-main-release">🔥 Step 9: Merge Develop → Main (Release)</h1>
<p>When your features are tested and stable:</p>
<pre><code class="lang-plaintext">git checkout main
git merge develop
git push origin main
</code></pre>
<p>Now production (<code>main</code>) is updated 🎉</p>
<hr />
<h1 id="heading-final-branch-structure">📊 Final Branch Structure</h1>
<pre><code class="lang-plaintext">main
develop
feature/login
feature/dashboard
feature/payment
</code></pre>
<hr />
<h1 id="heading-optional-delete-feature-branch-after-merge">🧼 Optional: Delete Feature Branch After Merge</h1>
<pre><code class="lang-plaintext">git branch -d feature/login
git push origin --delete feature/login
</code></pre>
<p>Keeps your repo clean.</p>
<hr />
<h1 id="heading-real-world-flow-summary">🎯 Real-World Flow Summary</h1>
<pre><code class="lang-plaintext">1. Create repo
2. Create develop
3. Create feature branch from develop
4. Commit changes
5. Push feature
6. Merge feature → develop
7. Push develop
8. Merge develop → main
</code></pre>
]]></content:encoded></item><item><title><![CDATA[Building a Reusable Styled Table Using Web Components (Step-by-Step)]]></title><description><![CDATA[Web Components allow us to create reusable, framework-free UI components using native browser APIs. In this article, we’ll build a styled table component that:

Works like a custom HTML tag

Has scoped CSS using Shadow DOM

Accepts headers via HTML a...]]></description><link>https://frontend-baat-cheet.hashnode.dev/building-a-reusable-styled-table-using-web-components-step-by-step</link><guid isPermaLink="true">https://frontend-baat-cheet.hashnode.dev/building-a-reusable-styled-table-using-web-components-step-by-step</guid><category><![CDATA[JavaScript]]></category><dc:creator><![CDATA[paras jain]]></dc:creator><pubDate>Thu, 05 Feb 2026 06:44:24 GMT</pubDate><content:encoded><![CDATA[<p>Web Components allow us to create <strong>reusable, framework-free UI components</strong> using native browser APIs. In this article, we’ll build a <strong>styled table component</strong> that:</p>
<ul>
<li><p>Works like a custom HTML tag</p>
</li>
<li><p>Has scoped CSS using Shadow DOM</p>
</li>
<li><p>Accepts headers via HTML attributes</p>
</li>
<li><p>Accepts data via JavaScript</p>
</li>
</ul>
<p>No React. No Vue. Just pure JavaScript.</p>
<hr />
<h2 id="heading-step-1-indexhtml-using-the-custom-element">Step 1: <code>index.html</code> – Using the Custom Element</h2>
<pre><code class="lang-plaintext">&lt;!DOCTYPE html&gt;
&lt;html lang="en"&gt;
&lt;head&gt;
  &lt;meta charset="UTF-8" /&gt;
  &lt;title&gt;Web Components Table&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;

  &lt;styled-table
    id="users"
    data-headers="ID, Username, Country"&gt;
  &lt;/styled-table&gt;

  &lt;script type="module" src="./index.js"&gt;&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
<h3 id="heading-explanation">Explanation</h3>
<ul>
<li><p><code>&lt;styled-table&gt;</code> is <strong>not a native HTML tag</strong> — we’ll define it ourselves.</p>
</li>
<li><p><code>data-headers</code> is a <strong>configuration attribute</strong> that controls table headers.</p>
</li>
<li><p><code>type="module"</code> is required to use ES module imports in the browser.</p>
</li>
</ul>
<p>At this point, the browser doesn’t know what <code>&lt;styled-table&gt;</code> is — we’ll fix that next.</p>
<hr />
<h2 id="heading-step-2-indexjs-registering-the-web-component">Step 2: <code>index.js</code> – Registering the Web Component</h2>
<pre><code class="lang-plaintext">import { StyledTable } from "./components/styled-table.js";

customElements.define("styled-table", StyledTable);

const usersTable = document.getElementById("users");

const data = [
  ["8831", "dcode", "Australia"],
  ["8832", "paras", "India"]
];

usersTable.data = data;
</code></pre>
<h3 id="heading-explanation-1">Explanation</h3>
<ul>
<li><p><code>customElements.define()</code> registers a new HTML tag.</p>
</li>
<li><p>Custom element names <strong>must contain a dash</strong>.</p>
</li>
<li><p>Once registered, the browser understands <code>&lt;styled-table&gt;</code>.</p>
</li>
</ul>
<p>We also assign data using:</p>
<pre><code class="lang-plaintext">usersTable.data = ...
</code></pre>
<p>This works because the component exposes a <strong>setter</strong>, which we’ll implement later.</p>
<hr />
<h2 id="heading-step-3-creating-the-custom-element-class">Step 3: Creating the Custom Element Class</h2>
<p><code>components/styled-table.js</code></p>
<pre><code class="lang-plaintext">export class StyledTable extends HTMLElement {

  constructor() {
    super();
    this.attachShadow({ mode: "open" });
  }
</code></pre>
<h3 id="heading-explanation-2">Explanation</h3>
<ul>
<li><p><code>extends HTMLElement</code> tells the browser this is a custom HTML element.</p>
</li>
<li><p><code>super()</code> is required to properly initialize the element.</p>
</li>
<li><p><code>attachShadow({ mode: "open" })</code> creates a <strong>Shadow DOM</strong>, which:</p>
<ul>
<li><p>Isolates HTML and CSS</p>
</li>
<li><p>Prevents global styles from leaking in</p>
</li>
<li><p>Keeps component styles scoped</p>
</li>
</ul>
</li>
</ul>
<hr />
<h2 id="heading-step-4-lifecycle-connectedcallback">Step 4: Lifecycle – <code>connectedCallback()</code></h2>
<pre><code class="lang-plaintext">  connectedCallback() {
    const headers = this.dataset.headers
      ?.split(",")
      .map(h =&gt; h.trim()) || [];

    this.shadowRoot.innerHTML = `
      &lt;link rel="stylesheet" href="/components/sl.css"&gt;

      &lt;table&gt;
        &lt;thead&gt;
          &lt;tr&gt;
            ${headers.map(h =&gt; `&lt;th&gt;${h}&lt;/th&gt;`).join("")}
          &lt;/tr&gt;
        &lt;/thead&gt;
        &lt;tbody&gt;&lt;/tbody&gt;
      &lt;/table&gt;
    `;
  }
</code></pre>
<h3 id="heading-explanation-3">Explanation</h3>
<ul>
<li><p><code>connectedCallback()</code> runs when the element is <strong>added to the DOM</strong>.</p>
</li>
<li><p><code>this.dataset.headers</code> reads <code>data-headers</code> from HTML.</p>
</li>
<li><p><code>split(",") + trim()</code> converts the string into a clean array.</p>
</li>
<li><p>We generate <code>&lt;th&gt;</code> elements dynamically using <code>map()</code>.</p>
</li>
</ul>
<p>This makes the component <strong>configurable from HTML</strong>.</p>
<hr />
<h2 id="heading-step-5-scoped-styling-with-shadow-dom">Step 5: Scoped Styling with Shadow DOM</h2>
<p><code>components/sl.css</code></p>
<pre><code class="lang-plaintext">table {
  border-collapse: collapse;
  font-family: Inter, sans-serif;
  font-size: 0.85rem;
  min-width: 400px;
}

thead tr {
  background-color: #009578;
  color: white;
  text-align: left;
}

th, td {
  padding: 6px 12px;
  font-weight: normal;
}

tbody tr {
  border-bottom: 1px solid #ddd;
}

tbody tr:nth-of-type(even) {
  background-color: #f3f3f3;
}
</code></pre>
<h3 id="heading-explanation-4">Explanation</h3>
<ul>
<li><p>The CSS is loaded <strong>inside the Shadow DOM</strong>.</p>
</li>
<li><p>These styles <strong>only affect this component</strong>.</p>
</li>
<li><p>No class names are needed — we can target elements directly.</p>
</li>
</ul>
<p>This is one of the biggest advantages of Web Components.</p>
<hr />
<h2 id="heading-step-6-passing-data-via-a-public-api">Step 6: Passing Data via a Public API</h2>
<p>Back in <code>styled-table.js</code>:</p>
<pre><code class="lang-plaintext">  set data(data) {
    const tbody = this.shadowRoot.querySelector("tbody");

    tbody.innerHTML = "";

    const rows = data.map(rowData =&gt; {
      const row = document.createElement("tr");

      const cells = rowData.map(cellData =&gt; {
        const cell = document.createElement("td");
        cell.textContent = cellData;
        return cell;
      });

      row.append(...cells);
      return row;
    });

    tbody.append(...rows);
  }
}
</code></pre>
<h3 id="heading-explanation-5">Explanation</h3>
<ul>
<li><p>We expose a <strong>setter</strong> called <code>data</code>.</p>
</li>
<li><p>This allows clean usage like:</p>
<pre><code class="lang-plaintext">  table.data = [...]
</code></pre>
</li>
<li><p>The component controls how the DOM is updated.</p>
</li>
<li><p>External code never touches internal markup.</p>
</li>
</ul>
<p>This pattern makes the component <strong>safe, reusable, and maintainable</strong>.</p>
<hr />
<h2 id="heading-final-result">Final Result</h2>
<p>We now have:</p>
<ul>
<li><p>A custom HTML tag</p>
</li>
<li><p>Scoped HTML and CSS</p>
</li>
<li><p>Dynamic headers via attributes</p>
</li>
<li><p>Dynamic rows via JavaScript</p>
</li>
<li><p>Zero frameworks</p>
</li>
</ul>
<p>All using native browser APIs.</p>
<hr />
<h2 id="heading-when-should-you-use-web-components">When Should You Use Web Components?</h2>
<p>Web Components are perfect for:</p>
<ul>
<li><p>Design systems</p>
</li>
<li><p>Reusable widgets</p>
</li>
<li><p>Framework-agnostic UI libraries</p>
</li>
<li><p>Projects where you want long-term maintainability</p>
</li>
</ul>
<p>They can even coexist with React, Vue, or plain HTML.</p>
<hr />
<h2 id="heading-closing-thoughts">Closing Thoughts</h2>
<p>This example shows how powerful Web Components can be when used correctly. With Shadow DOM, lifecycle methods, and clean public APIs, we can build components that scale just like framework components — without the framework.</p>
]]></content:encoded></item><item><title><![CDATA[Pure CSS Carousel Walkthrough]]></title><description><![CDATA[I have converted the testimonial carousel from a JavaScript-based implementation to a pure CSS solution using the radio button technique.
Changes Made
1. HTML Overhaul

Added Hidden Radio Buttons: Two radio buttons (#dot-1 and #dot-2) were added to t...]]></description><link>https://frontend-baat-cheet.hashnode.dev/pure-css-carousel-walkthrough</link><guid isPermaLink="true">https://frontend-baat-cheet.hashnode.dev/pure-css-carousel-walkthrough</guid><dc:creator><![CDATA[paras jain]]></dc:creator><pubDate>Thu, 05 Feb 2026 06:41:34 GMT</pubDate><content:encoded><![CDATA[<p>I have converted the testimonial carousel from a JavaScript-based implementation to a pure CSS solution using the <strong>radio button technique</strong>.</p>
<h2 id="heading-changes-made"><strong>Changes Made</strong></h2>
<h3 id="heading-1-html-overhaul"><strong>1. HTML Overhaul</strong></h3>
<ul>
<li><p><strong>Added Hidden Radio Buttons</strong>: Two radio buttons (<code>#dot-1</code> and <code>#dot-2</code>) were added to the top of the testimonial section to track the carousel state.</p>
</li>
<li><p><strong>Converted Dots to Labels</strong>: The navigation dots are now <code>&lt;label&gt;</code> elements linked to the radio buttons using the <code>for</code> attribute. This allows clicking the dots to toggle the radio buttons without any JS.</p>
</li>
<li><p><strong>Removed Script Tag</strong>: The dedicated <code>&lt;script&gt;</code> block for carousel logic has been completely removed.</p>
</li>
</ul>
<h3 id="heading-2-scss-logic"><strong>2. SCSS Logic</strong></h3>
<ul>
<li><p><strong>State Selection</strong>: Using CSS sibling selectors (<code>#dot-n:checked ~ .testimonial-container</code>), the carousel now translates its position based on which radio button is active.</p>
</li>
<li><p><strong>Active Dot Highlights</strong>: The active "dot" (label) is now highlighted using CSS pseudo-states (<code>:checked</code>), removing the need for an <code>.active</code> class managed by JS.</p>
</li>
<li><p><strong>Transitions</strong>: The existing <code>transition: transform 0.5s ease-in-out;</code> on the carousel container ensures smooth movement.</p>
</li>
</ul>
<h2 id="heading-how-it-works"><strong>How it Works</strong></h2>
<pre><code class="lang-plaintext">TriggersCSS SelectorCSS SelectorUser clicks Label (Dot)Radio Button :checkedCarousel Translates (-100% or 0%)Label 스타일 (Active Style)
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769442399277/aced6fee-79ca-4b34-9468-a10457e688ba.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-verification"><strong>Verification</strong></h2>
<p><strong>NOTE</strong></p>
<p>Due to a browser environment issue, automated visual verification was not possible. However, the implementation follows standard no-JS patterns and has been logically verified.</p>
<h3 id="heading-code-verification"><strong>Code Verification</strong></h3>
<ul>
<li><p><strong>index.html</strong>: Verified radio inputs and label associations.</p>
</li>
<li><p><strong>_testimonial.scss</strong>: Verified translation logic and dot styling.</p>
</li>
<li><p><code>main.css</code>: The changes will be applied once SCSS is compiled.</p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Advanced JavaScript: Network Requests, Headers, Body & Postman]]></title><description><![CDATA[JavaScript allows you to interact with servers and APIs using network requests. Understanding this is essential for building dynamic web apps. Let’s break it down.

1. Network Requests in JavaScript
JavaScript communicates with servers via HTTP reque...]]></description><link>https://frontend-baat-cheet.hashnode.dev/advanced-javascript-network-requests-headers-body-and-postman</link><guid isPermaLink="true">https://frontend-baat-cheet.hashnode.dev/advanced-javascript-network-requests-headers-body-and-postman</guid><dc:creator><![CDATA[paras jain]]></dc:creator><pubDate>Tue, 03 Feb 2026 07:26:31 GMT</pubDate><content:encoded><![CDATA[<p>JavaScript allows you to interact with servers and APIs using <strong>network requests</strong>. Understanding this is essential for building dynamic web apps. Let’s break it down.</p>
<hr />
<h2 id="heading-1-network-requests-in-javascript"><strong>1. Network Requests in JavaScript</strong></h2>
<p>JavaScript communicates with servers via HTTP requests to <strong>fetch or send data</strong>.</p>
<h3 id="heading-a-fetch-api-modern-amp-promise-based"><strong>a) Fetch API (Modern &amp; Promise-based)</strong></h3>
<pre><code class="lang-plaintext">fetch('https://api.example.com/data')
  .then(response =&gt; response.json())  // parse JSON
  .then(data =&gt; console.log(data))
  .catch(error =&gt; console.error(error));
</code></pre>
<ul>
<li><p>Supports GET, POST, PUT, DELETE, etc.</p>
</li>
<li><p>Returns a <strong>Promise</strong>.</p>
</li>
<li><p>Can include <strong>headers</strong> and <strong>body</strong>.</p>
</li>
</ul>
<h3 id="heading-b-xmlhttprequest-older-callback-based"><strong>b) XMLHttpRequest (Older, Callback-based)</strong></h3>
<pre><code class="lang-plaintext">const xhr = new XMLHttpRequest();
xhr.open('GET', 'https://api.example.com/data');
xhr.onload = () =&gt; console.log(JSON.parse(xhr.responseText));
xhr.send();
</code></pre>
<ul>
<li><p>Works in all browsers.</p>
</li>
<li><p>Verbose; mostly replaced by <code>fetch</code>.</p>
</li>
</ul>
<h3 id="heading-c-axios-third-party-library"><strong>c) Axios (Third-party library)</strong></h3>
<pre><code class="lang-plaintext">axios.get('https://api.example.com/data')
  .then(res =&gt; console.log(res.data))
  .catch(err =&gt; console.error(err));
</code></pre>
<ul>
<li><p>Auto-parses JSON.</p>
</li>
<li><p>Handles timeouts, interceptors, and request cancellation.</p>
</li>
<li><p>Easier syntax for POST requests.</p>
</li>
</ul>
<hr />
<h2 id="heading-2-http-methods"><strong>2. HTTP Methods</strong></h2>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Method</td><td>Purpose</td></tr>
</thead>
<tbody>
<tr>
<td>GET</td><td>Fetch data</td></tr>
<tr>
<td>POST</td><td>Send data</td></tr>
<tr>
<td>PUT / PATCH</td><td>Update data</td></tr>
<tr>
<td>DELETE</td><td>Remove data</td></tr>
</tbody>
</table>
</div><hr />
<h2 id="heading-3-request-headers"><strong>3. Request Headers</strong></h2>
<p>Headers provide <strong>metadata</strong> about the request.</p>
<p><strong>Example:</strong></p>
<pre><code class="lang-plaintext">fetch('https://api.example.com/data', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',  
    'Authorization': 'Bearer token123'
  },
  body: JSON.stringify({ name: 'Paras', age: 20 })
});
</code></pre>
<p><strong>Common Headers:</strong></p>
<ul>
<li><p><code>Content-Type</code>: Type of data (<code>application/json</code>, <code>text/plain</code>, etc.)</p>
</li>
<li><p><code>Authorization</code>: API token or credentials</p>
</li>
<li><p><code>Accept</code>: Expected response format</p>
</li>
<li><p>Custom headers: Any server-specific info</p>
</li>
</ul>
<hr />
<h2 id="heading-4-request-body"><strong>4. Request Body</strong></h2>
<ul>
<li><p>Used in <strong>POST, PUT, PATCH</strong> requests.</p>
</li>
<li><p>Can be JSON, FormData, URL-encoded, etc.</p>
</li>
</ul>
<p><strong>JSON Body:</strong></p>
<pre><code class="lang-plaintext">fetch('/api/user', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ username: 'Paras', password: '12345' })
});
</code></pre>
<p><strong>FormData (for files or forms):</strong></p>
<pre><code class="lang-plaintext">const formData = new FormData();
formData.append('file', fileInput.files[0]);
fetch('/upload', { method: 'POST', body: formData });
</code></pre>
<hr />
<h2 id="heading-5-postman"><strong>5. Postman</strong></h2>
<p>A GUI tool to <strong>test APIs</strong> without writing code.</p>
<ul>
<li><p>Set URL &amp; HTTP method.</p>
</li>
<li><p>Add headers &amp; body.</p>
</li>
<li><p>View responses and status codes.</p>
</li>
<li><p>Useful for debugging APIs before integrating with JS.</p>
</li>
</ul>
<p><strong>Example workflow:</strong></p>
<ol>
<li><p>URL: <code>https://api.example.com/login</code></p>
</li>
<li><p>Method: POST</p>
</li>
<li><p>Headers: <code>Content-Type: application/json</code></p>
</li>
<li><p>Body: <code>{ "username": "Paras", "password": "12345" }</code></p>
</li>
<li><p>Click <strong>Send</strong> → Inspect JSON response</p>
</li>
</ol>
<hr />
<h2 id="heading-6-hands-on-practice"><strong>6. Hands-on Practice</strong></h2>
<p>Try the free API <a target="_blank" href="https://jsonplaceholder.typicode.com/">JSONPlaceholder</a>:</p>
<pre><code class="lang-plaintext">// GET request
fetch('https://jsonplaceholder.typicode.com/posts/1')
  .then(res =&gt; res.json())
  .then(console.log);

// POST request
fetch('https://jsonplaceholder.typicode.com/posts', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ title: 'Hello', body: 'JS is fun', userId: 1 })
})
.then(res =&gt; res.json())
.then(console.log);
</code></pre>
<hr />
<p>💡 <strong>Pro Tip:</strong> Always check the <strong>network tab</strong> in DevTools to debug requests and responses. Combine it with Postman for a smoother workflow.</p>
]]></content:encoded></item><item><title><![CDATA[3D Cube Flip Card Using Pure HTML & CSS]]></title><description><![CDATA[These notes explain how to build a 3D cube-style flip card step by step using only HTML and CSS, exactly like a team/people card that shows an image on the front and rotates to reveal content on hover.
This is written for future reference + blog post...]]></description><link>https://frontend-baat-cheet.hashnode.dev/3d-cube-flip</link><guid isPermaLink="true">https://frontend-baat-cheet.hashnode.dev/3d-cube-flip</guid><category><![CDATA[HTML5]]></category><category><![CDATA[CSS]]></category><category><![CDATA[3d]]></category><category><![CDATA[animation]]></category><dc:creator><![CDATA[paras jain]]></dc:creator><pubDate>Sat, 24 Jan 2026 11:37:46 GMT</pubDate><content:encoded><![CDATA[<p>These notes explain <strong>how to build a 3D cube-style flip card</strong> step by step using <strong>only HTML and CSS</strong>, exactly like a team/people card that shows an image on the front and rotates to reveal content on hover.</p>
<p>This is written for <strong>future reference + blog posting (Hashnode)</strong> and focuses on <strong>why each step exists</strong>, not just what to write.</p>
<hr />
<h2 id="heading-1-the-goal-mental-model">1. The Goal (Mental Model)</h2>
<p>We are not making a normal flip card.</p>
<p>We are simulating <strong>a 3D cube rotation</strong>:</p>
<ul>
<li><p>Front face → Image</p>
</li>
<li><p>Side face → Text (name + bio)</p>
</li>
<li><p>On hover → cube rotates <strong>90° on Y-axis</strong></p>
</li>
</ul>
<p>Key idea:</p>
<blockquote>
<p>The browser must believe the element has <strong>depth</strong>.</p>
</blockquote>
<hr />
<h2 id="heading-2-required-html-structure-very-important">2. Required HTML Structure (Very Important)</h2>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"card"</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"card-inner"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"card-front"</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">img</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"photo.png"</span> /&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"card-side"</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">h3</span>&gt;</span>Name<span class="hljs-tag">&lt;/<span class="hljs-name">h3</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>Description<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<h3 id="heading-why-this-structure">Why this structure?</h3>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Element</td><td>Role</td></tr>
</thead>
<tbody>
<tr>
<td><code>.card</code></td><td>Camera (perspective)</td></tr>
<tr>
<td><code>.card-inner</code></td><td>Cube (rotates)</td></tr>
<tr>
<td><code>.card-front</code></td><td>Front face</td></tr>
<tr>
<td><code>.card-side</code></td><td>Side face</td></tr>
</tbody>
</table>
</div><p>Never skip this nesting — 3D depends on it.</p>
<hr />
<h2 id="heading-3-card-container-camera">3. Card Container = Camera</h2>
<pre><code class="lang-css"><span class="hljs-selector-class">.card</span> {
  <span class="hljs-attribute">aspect-ratio</span>: <span class="hljs-number">1</span> / <span class="hljs-number">1</span>;
  <span class="hljs-attribute">position</span>: relative;
  <span class="hljs-attribute">perspective</span>: <span class="hljs-number">1000px</span>;
}
</code></pre>
<h3 id="heading-why-aspect-ratio-1-1">Why <code>aspect-ratio: 1 / 1</code>?</h3>
<ul>
<li><p>Forces a perfect square</p>
</li>
<li><p>Cube math only works correctly on equal width &amp; height</p>
</li>
</ul>
<h3 id="heading-why-position-relative">Why <code>position: relative</code>?</h3>
<ul>
<li><p>Anchors absolutely positioned faces</p>
</li>
<li><p>Prevents faces from escaping the card</p>
</li>
</ul>
<h3 id="heading-why-perspective">Why <code>perspective</code>?</h3>
<ul>
<li><p>Enables real 3D depth</p>
</li>
<li><p>Controls how dramatic the rotation looks</p>
</li>
</ul>
<p>Without perspective → everything looks flat.</p>
<hr />
<h2 id="heading-4-cube-depth-variable">4. Cube Depth Variable</h2>
<pre><code class="lang-css"><span class="hljs-selector-class">.card</span> {
  <span class="hljs-attribute">--depth</span>: <span class="hljs-number">150px</span>;
}
</code></pre>
<p>This represents <strong>half the cube thickness</strong>.</p>
<p>All faces will be positioned using this value.</p>
<hr />
<h2 id="heading-5-the-rotating-cube-card-inner">5. The Rotating Cube (<code>card-inner</code>)</h2>
<pre><code class="lang-css"><span class="hljs-selector-class">.card-inner</span> {
  <span class="hljs-attribute">width</span>: <span class="hljs-number">100%</span>;
  <span class="hljs-attribute">height</span>: <span class="hljs-number">100%</span>;
  <span class="hljs-attribute">position</span>: relative;
  <span class="hljs-attribute">transform-style</span>: preserve-<span class="hljs-number">3</span>d;
  <span class="hljs-attribute">transform</span>: <span class="hljs-built_in">translateZ</span>(calc(var(--depth) * -<span class="hljs-number">1</span>));
  <span class="hljs-attribute">transition</span>: transform <span class="hljs-number">0.6s</span> ease;
}
</code></pre>
<h3 id="heading-line-by-line-purpose">Line-by-line purpose:</h3>
<h4 id="heading-transform-style-preserve-3d"><code>transform-style: preserve-3d</code></h4>
<ul>
<li><p>Prevents browser from flattening child elements</p>
</li>
<li><p>Allows faces to exist on Z-axis</p>
</li>
</ul>
<p>Without it → no cube, no depth.</p>
<h4 id="heading-translatez-depth"><code>translateZ(-depth)</code></h4>
<ul>
<li><p>Pulls the entire cube backward</p>
</li>
<li><p>Balances faces that are pushed forward</p>
</li>
</ul>
<p>This <strong>centers the cube</strong> in 3D space.</p>
<hr />
<h2 id="heading-6-front-face-image-side">6. Front Face (Image Side)</h2>
<pre><code class="lang-css"><span class="hljs-selector-class">.card-front</span> {
  <span class="hljs-attribute">position</span>: absolute;
  <span class="hljs-attribute">inset</span>: <span class="hljs-number">0</span>;
  <span class="hljs-attribute">backface-visibility</span>: hidden;
  <span class="hljs-attribute">transform</span>: <span class="hljs-built_in">translateZ</span>(var(--depth));
}
</code></pre>
<h3 id="heading-what-each-line-does">What each line does:</h3>
<ul>
<li><p><code>position: absolute</code> → allows stacking</p>
</li>
<li><p><code>inset: 0</code> → fills the card perfectly</p>
</li>
<li><p><code>backface-visibility: hidden</code> → hides mirrored backside</p>
</li>
<li><p><code>translateZ(depth)</code> → pushes face to the front of cube</p>
</li>
</ul>
<p>This is what the user sees initially.</p>
<hr />
<h2 id="heading-7-side-face-text-side">7. Side Face (Text Side)</h2>
<pre><code class="lang-css"><span class="hljs-selector-class">.card-side</span> {
  <span class="hljs-attribute">position</span>: absolute;
  <span class="hljs-attribute">inset</span>: <span class="hljs-number">0</span>;
  <span class="hljs-attribute">backface-visibility</span>: hidden;
  <span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotateY</span>(<span class="hljs-number">90deg</span>) <span class="hljs-built_in">translateZ</span>(var(--depth));
}
</code></pre>
<h3 id="heading-key-idea">Key idea:</h3>
<p>This face starts <strong>turned sideways</strong>, so it is invisible.</p>
<ul>
<li><p><code>rotateY(90deg)</code> → faces sideways</p>
</li>
<li><p><code>translateZ(depth)</code> → places it on cube edge</p>
</li>
</ul>
<p>This is NOT the back — it is the <strong>side of the cube</strong>.</p>
<hr />
<h2 id="heading-8-hover-rotation">8. Hover Rotation</h2>
<pre><code class="lang-css"><span class="hljs-selector-class">.card</span><span class="hljs-selector-pseudo">:hover</span> <span class="hljs-selector-class">.card-inner</span> {
  <span class="hljs-attribute">transform</span>: <span class="hljs-built_in">translateZ</span>(calc(var(--depth) * -<span class="hljs-number">1</span>)) <span class="hljs-built_in">rotateY</span>(-<span class="hljs-number">90deg</span>);
}
</code></pre>
<h3 id="heading-what-happens-on-hover">What happens on hover:</h3>
<ol>
<li><p>Cube rotates left</p>
</li>
<li><p>Front face moves out of view</p>
</li>
<li><p>Side face rotates into view</p>
</li>
<li><p>Feels like a real cube turn</p>
</li>
</ol>
<p>Why <strong>90deg and not 180deg</strong>?</p>
<ul>
<li><p>180deg = flip card</p>
</li>
<li><p>90deg = cube rotation</p>
</li>
</ul>
<hr />
<h2 id="heading-9-why-backface-visibility-is-mandatory">9. Why <code>backface-visibility</code> Is Mandatory</h2>
<p>Without it:</p>
<ul>
<li><p>Text appears mirrored</p>
</li>
<li><p>Faces overlap visually</p>
</li>
<li><p>Rotation looks broken</p>
</li>
</ul>
<p>With it:</p>
<ul>
<li>Only faces pointing toward the viewer are rendered</li>
</ul>
<hr />
<h2 id="heading-10-common-mistakes-and-why-they-break">10. Common Mistakes (and Why They Break)</h2>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Mistake</td><td>Result</td></tr>
</thead>
<tbody>
<tr>
<td>No <code>perspective</code></td><td>Flat animation</td></tr>
<tr>
<td>No <code>preserve-3d</code></td><td>Faces collapse</td></tr>
<tr>
<td>No <code>translateZ(-depth)</code></td><td>Off-center rotation</td></tr>
<tr>
<td>Using 180deg</td><td>Wrong animation</td></tr>
<tr>
<td>No <code>aspect-ratio</code></td><td>Distorted cube</td></tr>
</tbody>
</table>
</div><hr />
<h2 id="heading-11-one-paragraph-explanation-interview-blog">11. One-Paragraph Explanation (Interview / Blog)</h2>
<blockquote>
<p>I create a 3D cube effect by placing two faces in 3D space using <code>translateZ</code> and <code>rotateY</code>, preserving depth with <code>transform-style: preserve-3d</code>, and rotating the inner wrapper by 90 degrees on hover. The parent element provides perspective, while the cube is centered using a negative Z translation to maintain correct rotation geometry.</p>
</blockquote>
<hr />
<h2 id="heading-12-final-takeaway">12. Final Takeaway</h2>
<p><strong>3D CSS is about balance</strong>:</p>
<ul>
<li><p>Faces go forward</p>
</li>
<li><p>Cube goes backward</p>
</li>
<li><p>Camera stays outside</p>
</li>
</ul>
<p>When all three are correct → the illusion works.</p>
<hr />
]]></content:encoded></item><item><title><![CDATA[CSS Media Queries]]></title><description><![CDATA[📱 CSS Media Queries – Simple Cheat Sheet
Media queries let you apply CSS only when certain conditions are true, like screen size, device type, or user preferences.

🧠 Basic Syntax
@media (condition) {
  /* CSS rules */
}

Example:
@media (max-width...]]></description><link>https://frontend-baat-cheet.hashnode.dev/css-media-queries</link><guid isPermaLink="true">https://frontend-baat-cheet.hashnode.dev/css-media-queries</guid><category><![CDATA[CSS]]></category><category><![CDATA[media queries]]></category><dc:creator><![CDATA[paras jain]]></dc:creator><pubDate>Wed, 21 Jan 2026 08:18:18 GMT</pubDate><content:encoded><![CDATA[<h1 id="heading-css-media-queries-simple-cheat-sheet">📱 CSS Media Queries – Simple Cheat Sheet</h1>
<p>Media queries let you apply CSS <strong>only when certain conditions are true</strong>, like screen size, device type, or user preferences.</p>
<hr />
<h2 id="heading-basic-syntax">🧠 Basic Syntax</h2>
<pre><code class="lang-css"><span class="hljs-keyword">@media</span> (condition) {
  <span class="hljs-comment">/* CSS rules */</span>
}
</code></pre>
<p>Example:</p>
<pre><code class="lang-css"><span class="hljs-keyword">@media</span> (<span class="hljs-attribute">max-width:</span> <span class="hljs-number">600px</span>) {
  <span class="hljs-selector-tag">body</span> {
    <span class="hljs-attribute">background</span>: lightblue;
  }
}
</code></pre>
<p>👉 Applies <strong>only when screen width is 600px or less</strong>.</p>
<hr />
<h2 id="heading-screen-width-most-common">📏 Screen Width (Most Common)</h2>
<h3 id="heading-mobile-first-recommended">Mobile First (Recommended ✅)</h3>
<pre><code class="lang-css"><span class="hljs-comment">/* Default = mobile */</span>

<span class="hljs-keyword">@media</span> (<span class="hljs-attribute">min-width:</span> <span class="hljs-number">768px</span>) {
  <span class="hljs-comment">/* Tablet and up */</span>
}

<span class="hljs-keyword">@media</span> (<span class="hljs-attribute">min-width:</span> <span class="hljs-number">1024px</span>) {
  <span class="hljs-comment">/* Laptop and up */</span>
}
</code></pre>
<h3 id="heading-desktop-first">Desktop First</h3>
<pre><code class="lang-css"><span class="hljs-keyword">@media</span> (<span class="hljs-attribute">max-width:</span> <span class="hljs-number">1024px</span>) {
  <span class="hljs-comment">/* Tablet and below */</span>
}

<span class="hljs-keyword">@media</span> (<span class="hljs-attribute">max-width:</span> <span class="hljs-number">600px</span>) {
  <span class="hljs-comment">/* Mobile */</span>
}
</code></pre>
<hr />
<h2 id="heading-common-breakpoints-easy-to-remember">📱 Common Breakpoints (Easy to Remember)</h2>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Device</td><td>Width</td></tr>
</thead>
<tbody>
<tr>
<td>Small phones</td><td>≤ 480px</td></tr>
<tr>
<td>Phones</td><td>≤ 600px</td></tr>
<tr>
<td>Tablets</td><td>≥ 768px</td></tr>
<tr>
<td>Laptops</td><td>≥ 1024px</td></tr>
<tr>
<td>Large screens</td><td>≥ 1200px</td></tr>
</tbody>
</table>
</div><hr />
<h2 id="heading-only-screen-explained">🖥️ <code>only screen</code> Explained</h2>
<pre><code class="lang-css"><span class="hljs-keyword">@media</span> <span class="hljs-keyword">only</span> screen <span class="hljs-keyword">and</span> (<span class="hljs-attribute">max-width:</span> <span class="hljs-number">600px</span>) {
  <span class="hljs-comment">/* CSS */</span>
}
</code></pre>
<ul>
<li><p><code>screen</code> → targets screens (not print)</p>
</li>
<li><p><code>only</code> → ignores very old browsers</p>
</li>
<li><p><strong>Optional</strong> in modern projects</p>
</li>
</ul>
<hr />
<h2 id="heading-orientation-portrait-landscape">🧭 Orientation (Portrait / Landscape)</h2>
<pre><code class="lang-css"><span class="hljs-keyword">@media</span> (<span class="hljs-attribute">orientation:</span> portrait) {
  <span class="hljs-comment">/* Phone held vertically */</span>
}

<span class="hljs-keyword">@media</span> (<span class="hljs-attribute">orientation:</span> landscape) {
  <span class="hljs-comment">/* Phone held horizontally */</span>
}
</code></pre>
<hr />
<h2 id="heading-user-preferences-accessibility">♿ User Preferences (Accessibility)</h2>
<h3 id="heading-reduce-motion-very-important">Reduce Motion (Very Important)</h3>
<pre><code class="lang-css"><span class="hljs-keyword">@media</span> (<span class="hljs-attribute">prefers-reduced-motion:</span> reduce) {
  * {
    <span class="hljs-attribute">animation</span>: none <span class="hljs-meta">!important</span>;
    <span class="hljs-attribute">transition</span>: none <span class="hljs-meta">!important</span>;
  }
}
</code></pre>
<p>👉 Respects users who dislike animations.</p>
<h3 id="heading-dark-mode">Dark Mode</h3>
<pre><code class="lang-css"><span class="hljs-keyword">@media</span> (<span class="hljs-attribute">prefers-color-scheme:</span> dark) {
  <span class="hljs-selector-tag">body</span> {
    <span class="hljs-attribute">background</span>: black;
    <span class="hljs-attribute">color</span>: white;
  }
}
</code></pre>
<hr />
<h2 id="heading-print-media">🖨️ Print Media</h2>
<pre><code class="lang-css"><span class="hljs-keyword">@media</span> print {
  <span class="hljs-selector-tag">nav</span>, <span class="hljs-selector-tag">footer</span> {
    <span class="hljs-attribute">display</span>: none;
  }
}
</code></pre>
<p>👉 Applies when <strong>printing the page</strong>.</p>
<hr />
<h2 id="heading-multiple-conditions">🔗 Multiple Conditions</h2>
<pre><code class="lang-css"><span class="hljs-keyword">@media</span> (<span class="hljs-attribute">min-width:</span> <span class="hljs-number">600px</span>) <span class="hljs-keyword">and</span> (<span class="hljs-attribute">max-width:</span> <span class="hljs-number">900px</span>) {
  <span class="hljs-comment">/* Only tablets */</span>
}
</code></pre>
<hr />
<h2 id="heading-common-mistakes">❌ Common Mistakes</h2>
<p>❌ Forgetting <code>px</code></p>
<pre><code class="lang-css">(<span class="hljs-selector-tag">max-width</span>: 600) <span class="hljs-comment">/* WRONG */</span>
</code></pre>
<p>✅ Correct</p>
<pre><code class="lang-css">(<span class="hljs-selector-tag">max-width</span>: 600<span class="hljs-selector-tag">px</span>)
</code></pre>
<p>❌ Overusing too many breakpoints</p>
<hr />
<h2 id="heading-easy-mental-model">🧠 Easy Mental Model</h2>
<ul>
<li><p><code>min-width</code> → <strong>"From this size and bigger"</strong></p>
</li>
<li><p><code>max-width</code> → <strong>"From this size and smaller"</strong></p>
</li>
</ul>
<hr />
<h2 id="heading-best-practices">✅ Best Practices</h2>
<p>✔ Prefer <strong>mobile-first</strong> (<code>min-width</code>)<br />✔ Keep breakpoints consistent<br />✔ Use media queries only when layout breaks<br />✔ Respect accessibility preferences</p>
<hr />
<h2 id="heading-one-line-summary">🚀 One-Line Summary</h2>
<blockquote>
<p>Media queries help your website <strong>adapt to screen sizes, devices, and user preferences</strong>.</p>
</blockquote>
<hr />
]]></content:encoded></item><item><title><![CDATA[Redux Toolkit in Apni Baat-Cheet]]></title><description><![CDATA[Redux Toolkit sunte hi lagta hai koi heavy sa library hai, lekin trust me, ye React ka best dost hai jab baat aati hai state management ki.
Soch lo tumhare app mein multiple components hain – sabko kuch na kuch data chahiye:

Counter value

Logged in...]]></description><link>https://frontend-baat-cheet.hashnode.dev/redux-toolkit-in-apni-baat-cheet</link><guid isPermaLink="true">https://frontend-baat-cheet.hashnode.dev/redux-toolkit-in-apni-baat-cheet</guid><category><![CDATA[Redux]]></category><category><![CDATA[redux-toolkit]]></category><category><![CDATA[Frontend Development]]></category><category><![CDATA[Learning Journey]]></category><category><![CDATA[React]]></category><dc:creator><![CDATA[paras jain]]></dc:creator><pubDate>Sun, 06 Apr 2025 08:02:08 GMT</pubDate><content:encoded><![CDATA[<p>Redux Toolkit sunte hi lagta hai koi heavy sa library hai, lekin trust me, ye React ka best dost hai jab baat aati hai <strong>state management</strong> ki.</p>
<p>Soch lo tumhare app mein multiple components hain – sabko kuch na kuch data chahiye:</p>
<ul>
<li><p>Counter value</p>
</li>
<li><p>Logged in user</p>
</li>
<li><p>Cart items</p>
</li>
</ul>
<p>Aur agar sab data ko alag-alag jagah store kiya, toh kya hoga? Yahi kaam Redux handle karta hai… aur <strong>Redux Toolkit</strong> uska easy version hai.</p>
<hr />
<h2 id="heading-but-first-redux-toolkit-kya-karta-hai">But first... Redux Toolkit kya karta hai?</h2>
<p>Redux Toolkit ek modern way hai Redux use karne ka – jisme:</p>
<ul>
<li><p>Less boilerplate (kam code)</p>
</li>
<li><p>More readability</p>
</li>
<li><p>Cleaner syntax</p>
</li>
</ul>
<hr />
<h2 id="heading-redux-toolkit-ke-3-core-concepts">Redux Toolkit ke 3 Core Concepts:</h2>
<h3 id="heading-1-reducers">1. <strong>Reducers</strong></h3>
<blockquote>
<p>“Reducers” woh functions hain jo state ko change karte hain based on actions.</p>
</blockquote>
<p>Jaise agar kisi ne bola “increment karo” toh reducer decide karega:</p>
<pre><code class="lang-javascript">reducers: {
  <span class="hljs-attr">increment</span>: <span class="hljs-function">(<span class="hljs-params">state</span>) =&gt;</span> {
    state.value += <span class="hljs-number">1</span>; <span class="hljs-comment">// state change yahin hota hai</span>
  },
  <span class="hljs-attr">decrement</span>: <span class="hljs-function">(<span class="hljs-params">state</span>) =&gt;</span> {
    state.value -= <span class="hljs-number">1</span>;
  },
  <span class="hljs-attr">addByAmount</span>: <span class="hljs-function">(<span class="hljs-params">state, action</span>) =&gt;</span> {
    state.value += action.payload;
  }
}
</code></pre>
<p><em>Reducers are like chefs – recipe milte hi mithai bana dete hain!</em></p>
<hr />
<h3 id="heading-2-dispatch">2. <strong>Dispatch</strong></h3>
<blockquote>
<h3 id="heading-dispatch-ka-kaam-hota-hai-batana-ki-kya-karna-hai">Dispatch ka kaam hota hai “batana” ki kya karna hai.</h3>
</blockquote>
<p>Tum <code>dispatch()</code> ko bula ke ek <strong>action</strong> bhejte ho reducer ke paas:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> dispatch = useDispatch();

<span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">onClick</span>=<span class="hljs-string">{()</span> =&gt;</span> dispatch(increment())}&gt;+<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span></span>
<span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">onClick</span>=<span class="hljs-string">{()</span> =&gt;</span> dispatch(addByAmount(5))}&gt;+5<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span></span>
</code></pre>
<p><em>Soch lo tumne ek message bheja: “5 laddoo aur chahiye” – reducer us par kaam karega.</em></p>
<hr />
<ol start="3">
<li><h3 id="heading-selector"><strong>Selector</strong></h3>
</li>
</ol>
<blockquote>
<p>Selector ka kaam hota hai Redux store se data uthana – bina kuch badle.</p>
</blockquote>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> count = useSelector(<span class="hljs-function">(<span class="hljs-params">state</span>) =&gt;</span> state.counter.value);
</code></pre>
<p><em>Soch lo tum store ki dukaan ke window se dekh rahe ho andar kya chal raha hai – bina andar jaaye.</em></p>
<hr />
<h3 id="heading-ek-choti-summary-table-for-quick-yaad-dasht">Ek choti summary table for quick yaad-dasht:</h3>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Concept</td><td>Kaam kya karta hai</td><td>Example</td></tr>
</thead>
<tbody>
<tr>
<td><code>reducer</code></td><td>State update karta hai</td><td><code>state.value += 1</code></td></tr>
<tr>
<td><code>dispatch()</code></td><td>Action bhejta hai reducer ko</td><td><code>dispatch(increment())</code></td></tr>
<tr>
<td><code>useSelector</code></td><td>State ko read karta hai React component mein</td><td><code>useSelector((state) =&gt;</code> <a target="_blank" href="http://state.xyz"><code>state.xyz</code></a><code>)</code></td></tr>
</tbody>
</table>
</div><hr />
<h2 id="heading-redux-toolkit-ke-3-superheroes-syntax">Redux Toolkit ke 3 Superheroes (Syntax):</h2>
<h3 id="heading-1-createslice">1. <code>createSlice()</code>:</h3>
<blockquote>
<p>Think of it as a “Mini manager” of one part of your app</p>
</blockquote>
<p>Yeh function ek feature ke liye:</p>
<ul>
<li><p>State banata hai</p>
</li>
<li><p>Reducer likhta hai</p>
</li>
<li><p>Aur actions bhi ready kar deta hai</p>
</li>
</ul>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> counterSlice = createSlice({
  <span class="hljs-attr">name</span>: <span class="hljs-string">'counter'</span>,
  <span class="hljs-attr">initialState</span>: { <span class="hljs-attr">value</span>: <span class="hljs-number">0</span> },
  <span class="hljs-attr">reducers</span>: {
    <span class="hljs-attr">increment</span>: <span class="hljs-function">(<span class="hljs-params">state</span>) =&gt;</span> { state.value += <span class="hljs-number">1</span> },
    <span class="hljs-attr">decrement</span>: <span class="hljs-function">(<span class="hljs-params">state</span>) =&gt;</span> { state.value -= <span class="hljs-number">1</span> },
  }
});
</code></pre>
<p><em>Yeh ek chhota cake slice hai jo sirf “counter” feature ka taste sambhalta hai.</em></p>
<p>isme export ye ye krte h:</p>
<ul>
<li><p><strong>Actions Export</strong> – Named Export</p>
<pre><code class="lang-javascript">  <span class="hljs-keyword">export</span> <span class="hljs-keyword">const</span> { increment, decrement, addByAmount } = counterSlice.actions;
</code></pre>
<p>  Kya hota hai yeh?<br />  Yeh Redux Toolkit automatically tumhare reducers ke naam ke actions create karta hai, jinhe tum <code>dispatch()</code> karte ho components se.</p>
</li>
<li><p><strong>Reducer Export</strong> – Default Export</p>
<pre><code class="lang-javascript">  <span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> counterSlice.reducer;
</code></pre>
<p>  Kya hota hai yeh?</p>
<p>  Yeh actual reducer function hai jo tum configureStore me use karoge:</p>
</li>
</ul>
<hr />
<h3 id="heading-2-configurestore">2. <code>configureStore()</code>:</h3>
<blockquote>
<p>App ka <strong>dimaag (brain)</strong> – jahan sab slices ki info hoti hai</p>
</blockquote>
<pre><code class="lang-js"><span class="hljs-keyword">export</span> <span class="hljs-keyword">const</span> store = configureStore({
  <span class="hljs-attr">reducer</span>: {
    <span class="hljs-attr">counter</span>: counterReducer,
    <span class="hljs-attr">user</span>: userReducer,
    <span class="hljs-attr">cart</span>: cartReducer
  }
});
</code></pre>
<p>Isme tum saare slices ko combine karte ho. Yeh <strong>Redux ka big vault</strong> hai – jahan sab states padhe hote hain.</p>
<hr />
<h3 id="heading-3">3. <code>&lt;Provider store={store}&gt;</code>:</h3>
<blockquote>
<p>Isse tum React ko bolte ho:<br />"Bhai... Redux se mil le. Yeh tera naya best friend hai." 😄</p>
</blockquote>
<pre><code class="lang-jsx"><span class="hljs-comment">// in main.jsx</span>
<span class="hljs-keyword">import</span> { Provider } <span class="hljs-keyword">from</span> <span class="hljs-string">'react-redux'</span>;

<span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">Provider</span> <span class="hljs-attr">store</span>=<span class="hljs-string">{store}</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">App</span> /&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">Provider</span>&gt;</span></span>
</code></pre>
<p>Ab tumhare sab components use kar sakte hain:</p>
<ul>
<li><p><code>useSelector()</code> → state ko read karne ke liye</p>
</li>
<li><p><code>useDispatch()</code> → actions dispatch karne ke liye</p>
</li>
</ul>
<hr />
<h2 id="heading-real-example-counter-app">🛠️ Real Example: Counter App</h2>
<pre><code class="lang-js"><span class="hljs-comment">// counterSlice.js</span>
<span class="hljs-keyword">const</span> counterSlice = createSlice({
  <span class="hljs-attr">name</span>: <span class="hljs-string">'counter'</span>,
  <span class="hljs-attr">initialState</span>: { <span class="hljs-attr">value</span>: <span class="hljs-number">0</span> },
  <span class="hljs-attr">reducers</span>: {
    <span class="hljs-attr">increment</span>: <span class="hljs-function">(<span class="hljs-params">state</span>) =&gt;</span> { state.value++ },
    <span class="hljs-attr">decrement</span>: <span class="hljs-function">(<span class="hljs-params">state</span>) =&gt;</span> { state.value-- },
  }
});

<span class="hljs-keyword">export</span> <span class="hljs-keyword">const</span> { increment, decrement } = counterSlice.actions;
<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> counterSlice.reducer;
</code></pre>
<pre><code class="lang-jsx"><span class="hljs-comment">// CounterComponent.jsx</span>
<span class="hljs-keyword">const</span> dispatch = useDispatch();
<span class="hljs-keyword">const</span> count = useSelector(<span class="hljs-function">(<span class="hljs-params">state</span>) =&gt;</span> state.counter.value);

<span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">onClick</span>=<span class="hljs-string">{()</span> =&gt;</span> dispatch(increment())}&gt;+<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span></span>
<span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>{count}<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span></span>
<span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">onClick</span>=<span class="hljs-string">{()</span> =&gt;</span> dispatch(decrement())}&gt;-<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span></span>
</code></pre>
<hr />
<h2 id="heading-summary-redux-toolkit-ko-ek-mithai-ki-dukaan-samjho">Summary: Redux Toolkit ko ek mithai ki dukaan samjho:</h2>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Cheez</td><td>Role</td></tr>
</thead>
<tbody>
<tr>
<td><code>createSlice()</code></td><td>Mithai ka box (feature-specific data manager)</td></tr>
<tr>
<td><code>configureStore()</code></td><td>Saari mithaiyon ka godown (poori state)</td></tr>
<tr>
<td><code>useSelector()</code></td><td>Mithai dekhna</td></tr>
<tr>
<td><code>useDispatch()</code></td><td>Mithai lena / dena (trigger action)</td></tr>
<tr>
<td><code>&lt;Provider&gt;</code></td><td>App aur godown ke beech bridge</td></tr>
</tbody>
</table>
</div>]]></content:encoded></item></channel></rss>