- Instalaciones:
yarn add --dev jest babel-jest @babel/preset-env @babel/preset-react
yarn add --dev @testing-library/react @types/jest jest-environment-jsdom
- Opcional: Si usamos Fetch API en el proyecto:
import { useEffect, useMemo, useState } from 'react'; | |
export const useForm = ( initialForm = {}, formValidations = {}) => { | |
const [ formState, setFormState ] = useState( initialForm ); | |
const [ formValidation, setFormValidation ] = useState({}); | |
useEffect(() => { | |
createValidators(); | |
}, [ formState ]) |