Skip to main content

Featured

🎉 Day 46 — React Mastery Completed (Final Summary & Congratulations!)

🎉 Day 46 — React Mastery Completed (Final Summary & Congratulations!) Congratulations, developer! 👏 You’ve successfully completed the 45-Day React.js Roadmap — from understanding the fundamentals to mastering advanced concepts like Redux, Routing, Testing, and Deployment. 📘 What You’ve Learned ✅ React basics — Components, JSX, Props, and State ✅ Hooks — useState, useEffect, useRef, useMemo, and Custom Hooks ✅ Context API and Redux Toolkit for global state management ✅ Routing with React Router & Protected Routes ✅ Data fetching using Fetch API, Axios, React Query ✅ Advanced Patterns — Compound Components, Render Props, HOCs ✅ Styling — CSS Modules, Styled Components, Theming ✅ Animations, Accessibility, Testing, and Performance Optimization ✅ Deployment on Vercel, Netlify, or GitHub Pages 🧩 Final Project Ideas Now that you’re done, build real-world apps to polish your skills: 📝 Task ...

📘 Day 23 — Data Fetching with React Query / SWR

📘 Day 23 — Data Fetching with React Query / SWR

Instead of manually handling fetch states, libraries like React Query or SWR simplify data fetching, caching, and revalidation.

🔹 Example: Using React Query

import { useQuery } from "@tanstack/react-query";
import axios from "axios";

function Posts() {
  const { data, isLoading, error } = useQuery(["posts"], async () => {
    const res = await axios.get("https://jsonplaceholder.typicode.com/posts");
    return res.data;
  });

  if (isLoading) return <p>Loading...</p>;
  if (error) return <p>Error fetching data</p>;

  return (
    <ul>
      {data.slice(0, 5).map((p) => (
        <li key={p.id}>{p.title}</li>
      ))}
    </ul>
  );
}
  

💡 Benefits

  • Automatic caching and background updates.
  • Reduces boilerplate code for loading/error states.
  • Supports pagination and infinite queries easily.

Comments