Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

133
Views
No se puede mostrar un mensaje de brindis cuando se activa un error en un campo usando formularios de gancho de reacción

Estoy usando react-native y react-hook-form con react-native-toast-notifications para mostrar errores en mi formulario. Quiero activar un brindis. mostrar ('mi mensaje personalizado') si hay un error de validación particular en el campo, el componente se ve así:

 export default function RegisterScreen(props) { // we initialize Toasts const toast = useToast(); // loading state const [loading, setLoading] = useState(false); // we manage the errors const [newError, setNewError] = useState(); // we setup the use of dispatch const dispatch = useDispatch(); // setup of our form const { control, handleSubmit, formState: { errors }, } = useForm(); // our submit handler const onSubmit = async data => { setLoading(true); setNewError(null); console.log(data); try { await dispatch(authActions.signup(data.email, data.password)); } catch (err) { toast.show(err.message, { type: 'danger', duration: 4000 }); setLoading(false); } }; // returning the view return ( <> <ScrollView> {errors.email && toast.show('email invalid')} <Controller control={control} rules={{ required: true, }} render={({ field: { onChange, onBlur, value } }) => ( <Input placeholder='Solo emails válidos' onBlur={onBlur} onChangeText={onChange} value={value} error={errors.email} name={t('auth:email')} autoFocus keyboardType='email-address' autoComplete='email' autoCorrect={false} returnKeyType='next' textContentType='emailAddress' /> )} name='email' /> </> ); }

Al activar el error.email, quiero generar un Toast, pero me dice "Error: las cadenas de texto deben procesarse dentro de un componente". Probé también {error.email && ()=> toast.show('my message') y tampoco funciona.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!