All files / store hooks.ts

100% Statements 5/5
100% Branches 0/0
100% Functions 1/1
100% Lines 3/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 193x                   14x               3x
import {TypedUseSelectorHook, useDispatch, useSelector} from "react-redux";
import {AppDispatch, RootState} from "@/store/store";
 
/**
 * Hook typé pour dispatcher des actions Redux
 * @returns Fonction dispatch typée avec AppDispatch
 * @example
 * const dispatch = useAppDispatch();
 * dispatch(addToCart({ evenementId: 1, offreId: 2, quantity: 1 }));
 */
export const useAppDispatch = () => useDispatch<AppDispatch>();
 
/**
 * Hook typé pour sélectionner des données du store Redux
 * @example
 * const cartItems = useAppSelector(state => state.panier.items);
 * const itemCount = useAppSelector(state => state.panier.items.length);
 */
export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector;