Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

185
Visualizações
Formik with redux and material ui

i'm new using formik and redux, i tring creating a validation with yup using formik and redux, but a i can't make this work correctly before i implement formik redux logic he working correctly but my question is what i can implement inside formik a redux logic, above is my code:

export const Login = () => {
  const dispatch = useDispatch();
  const [value, setValue] = useState({ password: "", email: "" });
  
  const handleChange = (event) => {
    setValue({ ...value, [event.target.name]: event.target.value })
  };

  const handleSubmit = async (e) => {
    e.preventDefault();
    if (!value.email || !value.password) {
      return alert("Email and password are required");
    }

    dispatch(loginPending());

    try {
      const res = await login(value);
      dispatch(loginSuccess(res));
      dispatch(getUserSuccess(res));
    } catch (err) {
      dispatch(loginFailure(err));
    }
  };

  const formik = useFormik({
    initialValues: {
      email: "",
      password: "",
    },
    validationSchema: validationSchema,
  });

return (
      <form onSubmit={formik.handleSubmit}>
        <WrapperInput>
        <Label>E-Mail</Label>
        <FormattedMessage
          id="placeholder_email"
          defaultMessage="Enter your e-mail"
        >
          {(placeholder) => (
            <Input
              color="primary_orange"
              placeholder={placeholder[0]}
              name="email"
              value={formik.values.email}
              onChange={formik.handleChange}
              type="email"
              variant="outlined"
              validators={["required", "isEmail"]}
              errorMessages={["this field is required", "email is not valid"]}
              error={formik.touched.email && Boolean(formik.errors.email)}
              helperText={formik.touched.email && formik.errors.email}
            />
          )}
        </FormattedMessage>
      </WrapperInput>
      <WrapperButton>
        <PrimaryButton type="submit" variant="contained">
          Log In
        </PrimaryButton>
      </form>

)

}

i try send a value to login but formik have a values, i don`t know how i can make formik understand my value and not a values, if i can try send formik.value.email value is don't recognized for formik.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda