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. Typed Hooks — useAppDispatch / useAppSelector
RTK QueryIntermediate

Typed Hooks — useAppDispatch / useAppSelector

Pre-typed hooks বানিয়ে dispatch/selector-এ type safety — বাংলায়।

5টি অংশবাংলা ভাষায়
src/hooks/use-app-dispatch.tsts
ts
"use client";

import { useDispatch, useSelector } from "react-redux";


// সর্বত্র এই hooks ব্যবহার করুন —
// টাইপড, তাই ভুল হলে compile-time-ই জামাল
export const useAppDispatch = useDispatch.withTypes<AppDispatch>();
export const useAppSelector = useSelector.withTypes<RootState>();

কেন typed hooks

  • useDispatch()-এ টাইপ না দিলে error silent হয়
  • useSelector((state) => state.cart.items) — RootState টাইপ অনুযায়ী autocomplete
  • App বড় হলে RootState প্রতিটি file-এ import না করে hooks-থেকে আসে
Component-এ usetsx
tsx
const dispatch = useAppDispatch();
const items = useAppSelector((state) => state.cart.items);

<button onClick={() => dispatch(increment(product.id))}>
  +
</button>
React Redux v9

useDispatch.withTypes<T>() / useSelector.withTypes<T>() হলো official typed-hook pattern (React-Redux v9 client)। বা useDispatch<AppDispatch>()-ও পুরনো method-ভালো — কোনোটিই ঠিক।

শেষ প্যারায় নিজে practice করুন — কোড কপি করে নিজের এডিটরে চালিয়ে দেখুন।
আগেরReducers ও Actions — Cart LogicপরেরSelectors — useSelector ও Memoization
এই পেজে
Tech Tutor

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

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

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

mdanamolhasan1998@gmail.com