Download react-hook-form/src/logic/shouldRenderFormState.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 833 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-hook-form/src/logic/shouldRenderFormState.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-hook-form/src/logic/shouldRenderFormState.ts
-
curl -L -o shouldRenderFormState.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-hook-form/src/logic/shouldRenderFormState.ts
833 Bytes
| import { VALIDATION_MODE } from '../constants'; | |
| import type { | |
| FieldValues, | |
| FormState, | |
| InternalFieldName, | |
| ReadFormState, | |
| } from '../types'; | |
| import isEmptyObject from '../utils/isEmptyObject'; | |
| export default <T extends FieldValues, K extends ReadFormState>( | |
| formStateData: Partial<FormState<T>> & { | |
| name?: InternalFieldName; | |
| values?: T; | |
| }, | |
| _proxyFormState: K, | |
| updateFormState: (formState: Partial<FormState<T>>) => void, | |
| isRoot?: boolean, | |
| ) => { | |
| updateFormState(formStateData); | |
| const { name, ...formState } = formStateData; | |
| return ( | |
| isEmptyObject(formState) || | |
| Object.keys(formState).length >= Object.keys(_proxyFormState).length || | |
| Object.keys(formState).find( | |
| (key) => | |
| _proxyFormState[key as keyof ReadFormState] === | |
| (!isRoot || VALIDATION_MODE.all), | |
| ) | |
| ); | |
| }; | |