diff --git a/package.json b/package.json index d0ea7dc..5eb600f 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "1.3.0", + "version": "1.3.1", "name": "@kernelui/core", "description": "Kernel UI Core.", "scripts": { diff --git a/src/Utils.tsx b/src/Utils.tsx index 48dd5e7..0eec34a 100644 --- a/src/Utils.tsx +++ b/src/Utils.tsx @@ -1,4 +1,4 @@ -import React, {FormEvent, useCallback, useEffect, useRef} from "react"; +import React, {DependencyList, FormEvent, useCallback, useEffect, useRef} from "react"; export type Modify = Omit & R; @@ -54,8 +54,9 @@ export function usePreviousValue(currentValue: T): T /** * Create a callback for a form submit function that fully overrides default form behavior. * @param submitFunction The function to call on form submit. + * @param dependencies Submit function dependencies. */ -export function useFormSubmit(submitFunction: () => void): React.FormEventHandler +export function useFormSubmit(submitFunction: () => void, dependencies: DependencyList = []): React.FormEventHandler { // Use a memoized callback. return useCallback((event: React.FormEvent) => { @@ -63,5 +64,5 @@ export function useFormSubmit(submitFunction: () => void): React.FormEventHandle event.preventDefault(); submitFunction(); return false; - }, [submitFunction]); + }, [submitFunction, ...dependencies]); }