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

104
Vistas
ComponentDidMount isn't running

My code isn't hitting componentDidMount and returning back the data nor hitting the console.log within componentDidMount. The API is working fine.

It was working fine until I added 'searchTerm' state and onChangeHandler. Any ideas? Because of that all my component props that I'm sending down is returning undefined.

    constructor(props) {
        super(props)
        this.state = {
            allStudents: [],
            searchTerm: " ",
         }
        }

    componentDidMount() {
        fetch(API)
        .then(resp => resp.json())
        .then(students => {
            console.log("app", students)
            this.setState({
                allStudents: students.students
            })
        });
    }

    onSearchHandler = event => {
        console.log(event.target.value)
        event.preventDefault();
        this.setState({
            searchTerm: event.target.value})
    }


     render () {
         const { allStudents, searchTerm} = this.state
         return (
          <div className="App">
          <div>
          {console.log(allStudents)}
            <input
            style={{
            width: '100%',
            fontSize: 'x-large',
            border: '0',
            outline: 'none'}}
            type='text'
            placeholder='search by name...'
            onChange={this.onSearchHandler}
            />
          </div>
          <hr />
            <StudentContainer allStudents={allStudents}
                              searchTerm={searchTerm}
                              onSearchHandler={this.onSearchHandler} />
          </div>
         )
    }
 }
 export default App;
about 4 years ago · Juan Pablo Isaza
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