Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

196
Vistas
Reset input field in React (redux)

I am making a basic Todo application using redux, this is my first time using these methods of redux. I have a problem when I add the Todo the input field does not reset, I have tried various approaches and non seem to work.

For example: defaultValue, handleText on click to bring it back to an empty string, etc.

There are similar question on stack but non with my approach. Here is my code.

enter image description here

Reducer: enter image description here

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

In order to reset the value of the input field, you just need to set the state value of todos to an empty string, which you would do by calling:

setTodos('');

As you want to do that following the click, you can call setTodos following to the dispatch in the handleClick function:

const handleClick = () => {
  dispatch({ ... });
  setTodos('');
};

Additionally, you might want to initialize todos to a empty string instead of an array as it is used as a value for a text input:

const [todos, setTodos] = useState('');
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda