apps/mantine.dev/src/pages/hooks/use-counter.mdx
import { UseCounterDemos } from '@docs/demos'; import { Layout } from '@/layout'; import { MDX_DATA } from '@/mdx';
export default Layout(MDX_DATA.useCounter);
interface UseCounterOptions {
min?: number;
max?: number;
step?: number;
}
interface UseCounterHandlers {
increment: () => void;
decrement: () => void;
set: (value: number) => void;
reset: () => void;
}
type UseCounterReturnValue = [number, UseCounterHandlers];
function useCounter(
initialValue?: number,
options?: UseCounterOptions,
): UseCounterReturnValue
The UseCounterOptions, UseCounterHandlers, and UseCounterReturnValue types are exported from the @mantine/hooks package;
you can import them in your application:
import type { UseCounterOptions, UseCounterHandlers, UseCounterReturnValue } from '@mantine/hooks';