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

300
Vistas
Passing a variable in React but it is showing error

I am learning react and getting this error that onDelete is not defined but the tutorial which i am following is not getting the error. This is the Code also sharing a snipshot. Snip shot of Code Can anyone tell me why i am getting this error and how to resolve it

import React from 'react';
import TodoItem from './todoItem';

export default function Todos(props) {
  return (
    <div className="container">
        <h3 className="my-3 text-center">Todo's List</h3>
        { props.todos.map((todo)=> {
            return <TodoItem todo={todo} onDelete={onDelete}/>})
        }
   </div>
  )
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You cannot defined the props and don't tell them about the props so why this happened.

Updated this

import React from 'react';
import TodoItem from './todoItem';

export default function Todos(props) {
render(){ //Added
 const { onDelete } = this.props; //Added
  return (
    <div className="container">
        <h3 className="my-3 text-center">Todo's List</h3>
        { props.todos.map((todo)=> {
            return <TodoItem todo={todo} onDelete={onDelete}/>})
        }
   </div>
  )
 }
}

This is code file to map list items.

https://github.com/mashaimtahir/React/blob/master/todo-app%20v2/src/Components/counters.jsx

This the link of complete todo app.

https://github.com/mashaimtahir/React/tree/master/todo-app%20v2/src

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