BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/guarahooks/use-formik

UseFormik

guarahooks/use-formik
FreeHook

Custom wrapper for Formik.

Live preview

live · rendered by the registry
Rendered by guarahooks on their own page — this is the component running, not a screenshot of it.

Install it

npx shadcn@latest add https://guarahooks.com/r/use-formik.json

Source

registry/hooks/use-formik.tsxguarahooks.com/r/use-formik.json
1'use client';
2
3import { useCallback, useEffect } from 'react';
4
5import { FormikConfig, FormikHelpers, FormikValues, useFormik } from 'formik';
6
7/**
8 * Extended Formik return type with a simplified onSubmit handler.
9 */
10export type UseFormikReturn<T extends FormikValues> = ReturnType<
11 typeof useFormik<T>
12> & {
13 /**
14 * Returns a memoized submit handler that wraps Formik's handleSubmit.
15 *
16 * @param handler Function called when the form is submitted.
17 */
18 onSubmit: (
19 handler: (
20 values: T,
21 formikHelpers: FormikHelpers<T>,
22 ) => void | Promise<void>,
23 ) => (e?: React.FormEvent<HTMLFormElement>) => void;
24};
25
26/**
27 * Custom hook wrapping Formik's useFormik, providing a simplified onSubmit handler
28 * and optional debug logging of form state changes.
29 *
30 * @param config Formik configuration options.
31 * @returns Form methods and a memoized onSubmit helper.
32 */
33export function useFormikHook<T extends FormikValues = FormikValues>(
34 config: FormikConfig<T>,
35): UseFormikReturn<T> {
36 const formik = useFormik<T>(config);
37
38 const handleSubmit = useCallback(
39 (
40 handler: (
41 values: T,
42 formikHelpers: FormikHelpers<T>,
43 ) => void | Promise<void>,
44 ) => {
45 return (e?: React.FormEvent<HTMLFormElement>) => {
46 e?.preventDefault();
47 handler(formik.values, formik);
48 };
49 },
50 [formik],
51 );
52
53 // Debug: Log form values and errors in development mode
54 useEffect(() => {
55 if (process.env.NODE_ENV === 'development') {
56 console.debug('[useFormikHook] values:', formik.values);
57 console.debug('[useFormikHook] errors:', formik.errors);
58 }
59 }, [formik.values, formik.errors]);
60
61 return { ...formik, onSubmit: handleSubmit };
62}

Files it writes

  • registry/hooks/use-formik.tsx

Facts

Registry
guarahooks
Type
registry:hook
Access
Free
Files written
1
Licence
MIT
First indexed
2026-08-03
Last confirmed
today

Go to the source

Docs on guarahooks guarahooks.com h3rmel/guarahooks on GitHub Raw registry item This item as JSON

More from guarahooks

All 100 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
UseAbortControlleruse-abort-controllerguarahooksHooksFreeno deps
UseArrayStateuse-array-stateguarahooksHooksFreeno deps
UseAxiosuse-axiosguarahooksHooksFreeno deps
UseBatteryStatususe-battery-statusguarahooksHooksFreeno deps
UseBetterAuthuse-better-authguarahooksHooksFreeno deps
UseClickOutsideuse-click-outsideguarahooksHooksFreeno deps
UseConfirmuse-confirmguarahooksHooksFreeno deps
UseCookieuse-cookieguarahooksHooksFreeno deps
BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex