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

213
Visualizações
Redux-from with useState - how to connect with value from redux?

Is it possible to substitute the value from useState with the one coming from input? Or is there a way to do this using dispatch? I have tried many ways, but none of them work.

const renderInput = ({
    input,
    label,
    type,
    meta: { asyncValidating, touched, error },
}) => {
    const [value, setValue] = useState('default state');

    const onChange = event => {
        setValue(event.target.value);
        // + some logic here
    };

    return (
        <div>
            <label>{label}</label>
            <div className={asyncValidating ? 'async-validating' : ''}>
                <input {...input} value={value} onChange={onChange} type={type} placeholder={label} />
                {touched && error && <span>{error}</span>}
            </div>
        </div>
    );
};

const SelectingFormValuesForm = props => {

    const { type, handleSubmit, pristine, reset, submitting } = props;

    return (
        <form onSubmit={handleSubmit}>
            <div>
                <label>Name</label>
                <div>
                    <Field
                        name="name"
                        component={renderInput}
                        type="text"
                        placeholder="Dish name..."
                    />
                </div>
            </div>
        </form>
    );
};

SelectingFormValuesForm = reduxForm({
    form: 'selectingFormValues',
    validate,
    asyncValidate,
    // asyncBlurFields: ['name'],
})(SelectingFormValuesForm);

export default SelectingFormValuesForm;

This way, unfortunately, the value sent to the submit remains empty.

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