forked from react-hook-form/react-hook-form
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
👩🌾 close react-hook-form#12168 optimise re-render with validating fi…
…elds subscription (react-hook-form#12192) * 👩🌾 close react-hook-form#12168 optimise re-render with validating fields subscription * revert back the check * optimise the logic
- Loading branch information
1 parent
9bf2436
commit 364174d
Showing
2 changed files
with
28 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Field, Validate } from '../types'; | ||
import isFunction from '../utils/isFunction'; | ||
import isObject from '../utils/isObject'; | ||
|
||
const ASYNC_FUNCTION = 'AsyncFunction'; | ||
|
||
export default (fieldReference: Field['_f']) => | ||
(!fieldReference || !fieldReference.validate) && | ||
!!( | ||
(isFunction(fieldReference.validate) && | ||
fieldReference.validate.constructor.name === ASYNC_FUNCTION) || | ||
(isObject(fieldReference.validate) && | ||
Object.values(fieldReference.validate).find( | ||
(validateFunction: Validate<unknown, unknown>) => | ||
validateFunction.constructor.name === ASYNC_FUNCTION, | ||
)) | ||
); |