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

223
Views
'TypeError: props.todoList is undefined' in React

im creating a simple app using the FARM(Fast API,React, MongoDB). I was following a tutorial on YT(https://www.youtube.com/watch?v=OzUzrs8uJl8). Ive been trying to solve this problem for the last day but no luck, if anyone can help that would be greatly appreciated, thanks

Todo.js

import axios from "axios"
import React from "react"

function TodoItem(props) {
    const deleteTodoHandler = (title) => {
        axios.delete('http://localhost:8000/api/todo/${title}').then(res =>console.log(res.data))}
        return (
            <div>
                <p>
                    <span style={{ fontWeight: 'bold, underline'}}>{props.todo.title} : </span> {props.todo.description}
                    <button onClick={() => deleteTodoHandler(props.todo.title)}
                    className="btn btn-outline-danger my-2 mx-2" style= {{'borderRadius':'50px',}}>X</button>
                    <hr></hr>
                </p>
            </div>
        )
}

export default TodoItem;

TodoListView.js

import TodoItem from "./Todo"

 function TodoView(props) {
     return (

         <div>
             <ul>
                {props.todoList.map(todo => <TodoItem todo= 
                {todo} />)}
             </ul>
         </div>
     )
 }
export default TodoView

p.s. if its a syntax error im sorry

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The issue is here:

props.todoList

here todoList is coming from axios call and which is an async call and the data is not available on first render and you are trying to access some data which is not available that's why the error.

So use a conditional render like:

{
  ( props.todoList && props.todoList.length > 0 )
  ?
  props.todoList.map(todo => <TodoItem todo={todo} />)
  :
  null
}
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!