Download react-hook-form/src/logic/getRadioValue.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 555 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/react-hook-form/src/logic/getRadioValue.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/react-hook-form/src/logic/getRadioValue.ts
-
curl -L -o getRadioValue.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/react-hook-form/src/logic/getRadioValue.ts
555 Bytes
| type RadioFieldResult = { | |
| isValid: boolean; | |
| value: number | string | null; | |
| }; | |
| const defaultReturn: RadioFieldResult = { | |
| isValid: false, | |
| value: null, | |
| }; | |
| export default (options?: HTMLInputElement[]): RadioFieldResult => | |
| Array.isArray(options) | |
| ? options.reduce( | |
| (previous, option): RadioFieldResult => | |
| option && option.checked && !option.disabled | |
| ? { | |
| isValid: true, | |
| value: option.value, | |
| } | |
| : previous, | |
| defaultReturn, | |
| ) | |
| : defaultReturn; | |