Advertisement
metalni

Untitled

May 31st, 2023
981
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React from 'react'
  2. import { useFormContext, useController } from 'react-hook-form'
  3. import { StyledTextField } from '../Email/StyledEmail.styled'
  4. import { IEmailProps } from './types'
  5. import { LABELS } from './utils/labels'
  6. import { type FC } from 'react'
  7.  
  8. export const Email: FC<IEmailProps> = () => {
  9.   const {
  10.     control,
  11.     formState: { errors },
  12.   } = useFormContext()
  13.  
  14.   const { field } = useController({
  15.     name: 'email',
  16.     control,
  17.     defaultValue: '',
  18.   })
  19.  
  20.   return (
  21.     <StyledTextField
  22.       value={field.value}
  23.       type={LABELS.type}
  24.       placeholder={LABELS.placeholder}
  25.       error={!!errors[field.name]?.message}
  26.       onSubmit={field.onChange}
  27.       required
  28.       fullWidth
  29.     />
  30.   )
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement