How can i get the Id of the Todo Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of How can i get the Id of the Todo without wasting too much if your time.

The question is published on by Tutorial Guruji team.

am trying to delete am item by id but i keep get error, that each child should have a unique key after giving a it an id, what am i doing wrongly, why am i not getting the id

const TodoList = () => {

    const [input, setInput] = useState("");
    const [todos, setTodos] = useState([])

    const handleSubmit = e => {


        setTodos([...todos, input])

    const handleDelete = id => {

       let item =  todos.filter(todo => !== id)

    //    setTodos(item)

  return (
  <div className='todolist'>
      <h2>Todo List</h2>
          <input value={input} onChange={e => setInput(} placeholder='write something' />
          <button onClick={handleSubmit}>Add todo</button>
      { => (

          <div key={}  className='todolist__details'>
              <DeleteIcon onClick={() => handleDelete(} />

export default TodoList;


 {, i) => {
        <div key={i}  className='todolist__details'>
              <DeleteIcon onClick={() => handleDelete(} />

You can check how list and keys work in react in here

We are here to answer your question about How can i get the Id of the Todo - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji