useAppDispatch (state/hooks.ts)

prometheus · web/ui/mantine-ui/src/state/hooks.ts · typescript · Apache-2.0
ui

Typed Redux hooks for Mantine UI, providing useAppDispatch and useAppSelector with proper state typing.

// Source: https://github.com/prometheus/prometheus | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
import { useDispatch, useSelector } from "react-redux";
import type { RootState, AppDispatch } from "./store";

// Use these typed hooks throughout the app instead of plain `useDispatch` and `useSelector`
export const useAppDispatch = useDispatch.withTypes<AppDispatch>();
export const useAppSelector = useSelector.withTypes<RootState>();

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key