feat: design applications and first api calls
Co-authored-by: Walid <87608619+WalidKorchi@users.noreply.github.com>
This commit is contained in:
15
hooks/useFormState.tsx
Normal file
15
hooks/useFormState.tsx
Normal file
@ -0,0 +1,15 @@
|
||||
import { useState } from 'react'
|
||||
|
||||
export const formState = ['idle', 'loading', 'error', 'success'] as const
|
||||
|
||||
export type FormState = typeof formState[number]
|
||||
|
||||
export const useFormState = (
|
||||
initialFormState: FormState = 'idle'
|
||||
): [
|
||||
formState: FormState,
|
||||
setFormState: React.Dispatch<React.SetStateAction<FormState>>
|
||||
] => {
|
||||
const [formState, setFormState] = useState<FormState>(initialFormState)
|
||||
return [formState, setFormState]
|
||||
}
|
Reference in New Issue
Block a user