Download wp-calypso/packages/composite-checkout/src/lib/form-status.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 747 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/packages/composite-checkout/src/lib/form-status.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/packages/composite-checkout/src/lib/form-status.ts
-
curl -L -o form-status.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/packages/composite-checkout/src/lib/form-status.ts
747 Bytes
| import { useContext, useMemo } from 'react'; | |
| import { FormStatus, FormStatusController } from '../types'; | |
| import { FormStatusContext } from './form-status-context'; | |
| export function useFormStatus(): FormStatusController { | |
| const { formStatus, setFormStatus } = useContext( FormStatusContext ); | |
| const formStatusActions = useMemo( | |
| () => ( { | |
| setFormLoading: () => setFormStatus( FormStatus.LOADING ), | |
| setFormReady: () => setFormStatus( FormStatus.READY ), | |
| setFormSubmitting: () => setFormStatus( FormStatus.SUBMITTING ), | |
| setFormValidating: () => setFormStatus( FormStatus.VALIDATING ), | |
| } ), | |
| [ setFormStatus ] | |
| ); | |
| return useMemo( | |
| () => ( { | |
| ...formStatusActions, | |
| formStatus, | |
| } ), | |
| [ formStatus, formStatusActions ] | |
| ); | |
| } | |