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

123
Views
Advertencia: las funciones no son válidas como elemento secundario de React: los elementos de la lista no aparecen

Cuando compilo la aplicación, aparece esta advertencia en la consola:

Advertencia: las funciones no son válidas como hijo de React. Esto puede suceder si devuelve un Componente en lugar de hacerlo desde el procesamiento. O tal vez quisiste llamar a esta función en lugar de devolverla.

Mi aplicación.js:

 import "./App.css"; import React, { Component } from "react"; class App extends Component { constructor(props) { super(props); this.state = { toDoList: [], activeItem: { id: null, title: "", completed: false, }, editing: false, }; this.fetchTasks = this.fetchTasks.bind(this); } componentWillMount() { this.fetchTasks(); } fetchTasks() { console.log("Fetching..."); fetch("http://127.0.0.1:8000/api/task-list/") .then((response) => response.json()) .then((data) => this.setState({ toDoList: data, }) ); } render() { var tasks = this.state.toDoList; return ( <div className="container"> <div id="task-container"> <div id="form-wrapper"> <form id="form"> <div className="flex-wrapper"> <div style={{ flex: 6 }}> <input className="form-control" type="text" name="title" placeholder="Add task" /> </div> <div style={{ flex: 1 }}> <input className="btn btn-warning" id="submit" type="submit" name="Add" /> </div> </div> </form> </div> <div className="list-wrapper"> { (tasks.map = (task, index) => { return ( <div key="{index}" className="task-wrapper flex-wrapper"> <span>{task.title}</span> </div> )}) } </div> </div> </div> ); } } export default App;

Básicamente, estoy tratando de enumerar los elementos en la lista de API, pero me falta algo. ¿Alguien me ayuda con eso?

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

0

(tasks.map = (task, index) => { return ( <div key="{index}" className="task-wrapper flex-wrapper"> <span>{task.title}</span> </div> )})

Debiera ser:

 (tasks.map(task, index) => { return ( <div key="{index}" className="task-wrapper flex-wrapper"> <span>{task.title}</span> </div> )})
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!