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

235
Views
Cómo borrar el campo de entrada después de hacer clic en enviar en reaccionar js redux

Estoy desarrollando un pequeño proyecto para aprender a reaccionar con redux, tuve una buena vista de conectar reaccionar con redux. Estoy tratando de realizar una pequeña tarea que es borrar el cuadro de entrada después de presionar enviar, intenté usar restablecer, escribí una función separada para borrar el estado e incluí la lógica para borrar la entrada en el controlador handleSubmit, no obtuve el Rendimiento esperado. ¿Alguien puede guiarme cómo lograr esto? Gracias por adelantado.

 AddRemainder.js File : import React, { Component } from "react"; import { connect } from "react-redux"; import addRemainder from "../../redux/action.js"; class AddRemainderPage extends Component { state = { reminder: { title: "", }, }; handleChange = (e) => { const reminder = { ...this.state.reminder, title: e.target.value }; this.setState({ reminder }); }; handleSubmit = (e) => { e.preventDefault(); this.props.dispatch(addRemainder(this.state.reminder)); }; render() { return ( <div className="App"> <div> <h2>My First Redux UnderStanding</h2> <form onSubmit={this.handleSubmit}> <input type="text" onChange={this.handleChange} value={this.state.reminder.title} /> <input type="submit" value="Save" /> </form> </div> </div> ); } } const mapStateToProps = (state) => { return { reminderss: state.reminderss, }; }; export default connect(mapStateToProps)(AddRemainderPage); Action.JS File: const addRemainder = (text) => ({ type: "ADD_REMINDER", rem: text, }); export default addRemainder; Reducer.JS File: const intialState = { reminderss: [], }; const remindersReducer = (state = intialState, action) => { switch (action.type) { case "ADD_REMINDER": return { reminderss: [...state.reminderss, action.rem], }; default: return state; } }; export default remindersReducer;
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Prueba de esta manera:

 clearInput = () => { const reminder = { ...this.state.reminder, title: '' }; this.setState({ reminder }); }; handleSubmit = (e) => { e.preventDefault(); this.props.dispatch(addRemainder(this.state.reminder)); this.clearInput(); };
about 4 years ago · Juan Pablo Isaza Report
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!