Tech TutorBangla Web Documentation
Portfolio
HomeHTMLCSSTailwind CSSJavaScriptTypeScriptReactNext.jsNode.jsExpressSocket.IOExpoWordPressPostgreSQLPrismaPostgresNestJSMongoDBDockerTanStackTanStack TableRTK QueryGitGitHub
  • RTK Query Documentation39টি অধ্যায়
প্রযুক্তি নির্বাচন
HomeHTMLCSSTailwind CSSJavaScriptTypeScriptReactNext.jsNode.jsExpressSocket.IOExpoWordPressPostgreSQLPrismaPostgresNestJSMongoDBDockerTanStackTanStack TableRTK QueryGitGitHub
  • Redux Intro
  • Architecture
  • Redux Toolkit
  • Project Setup
  • Folder Structure
  • configureStore
  • Redux Provider
  • createSlice
  • Reducers & Actions
  • Typed Hooks
  • Selectors
  • Devtools
  • RTK Query
  • createApi
  • API Middleware
  • API Tags
  • Fetch List
  • Fetch Detail
  • Mutation — Create
  • Mutation CRUD
  • Cache Invalidation
  • Cache Lifecycle
  • Polling
  • Query Selectors
  • Optimistic Update
  • Cart Slice Full
  • Cart UI
  • Local vs Server
  • Listener Middleware
  • Error Handling
  • Loading States
  • Serializability
  • SSR Prefetch
  • Complete Flow
  • Complete Project
  • Production
  • Common Mistakes
  • Best Practices
  • Interview Q&A
  1. Docs
  2. RTK Query
  3. Fetch Detail — useGetProductByIdQuery
RTK QueryIntermediate

Fetch Detail — useGetProductByIdQuery

Parameter-সহ query, skip option, derived loading — বাংলায়।

5টি অংশবাংলা ভাষায়
src/components/products/product-detail.tsxtsx
tsx
"use client";

import { useGetProductQuery } from "@/features/orders/ordersService";

export function ProductDetail({ id }: { id: string | null }) {
  // id === null → hook disabled (skip)
  const { data, isLoading, isError } = useGetProductQuery(
    id ?? "",
    { skip: id === null },
  );

  if (isLoading) return <ProductDetailSkeleton />;
  if (isError) return <ErrorMessage title="Product পাওয়া যায়নি" />;

  return (
    <article>
      <h2>{data?.name}</h2>
      <p className="text-muted-foreground">{data?.description}</p>
      <span className="font-semibold">{data?.price} টাকা</span>
    </article>
  );
}

Important options

Optionকাজ
skipcondition-এ fetch এড়িয়ে যায় (ওই arg null-able)
refetchOnFocuswindow focus-এ refetch
refetchOnReconnectনেটওয়ার্ক এলে refetch
pollingIntervalperiodic refetch (ms)
selectFromResultcache-থেকে নির্দিষ্ট অংশ pick
styles-এ relationts
ts
// RTK Query-র arg থেকে URL-এ mapping
// (id: string) => "products/" + id
// query: (id) => "products/" + id
একই id পুনরায় fetch হয় না

মনে রাখুন — একই id-সহ hook একাধিক component-এ use করলে একটাই fetch, সবাই একই cache পায়। আর fetch শেষ হলে কোনো component unmount না করলে refetch হয় না — সেটাই cache-র সুবিধা।

শেষ প্যারায় নিজে practice করুন — কোড কপি করে নিজের এডিটরে চালিয়ে দেখুন।
আগেরFetch List — useGetProductsQueryপরেরMutation: Create Order
এই পেজে
Tech Tutor

বাংলায় ওয়েব ডেভেলপমেন্ট ডকুমেন্টেশন শিখুন — ধাপে ধাপে।

Homeসব ডকুমেন্টেশনQuick Startআমার নোটস

© 2026 Tech Tutor. বাংলায় শিখুন, বাংলায় গড়ুন।

mdanamolhasan1998@gmail.com