Skip to main content
Mejora de formato
Origen Enlace
user166844
user166844

Hola estoy comenzando en react.js y estoyEstoy creando una "Lista de tareas" pero me sale este error: "Error: Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops" This is the code

"Error: Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops"

Este es mi código:

import './App.css';

import List from './Components/List';
import TaskForm from './Components/TaskForm';

import TaskList from './Sample/TaskList.json'
class App extends React.Component{
  
  state = {
    taskLists: TaskList
  }
  
  addTask = (title,description) => {
    const newTask = {
      title: title,
      description: description,
      id: this.state.taskLists.length
    }
    this.setState({
      taskLists : [...this.state.taskLists, newTask]
    })
  }

  render(){
    return(
      <div>
        <TaskForm addTask={this.addTask} />
        <List tasks={this.state.taskLists} />
      </div>
    );
  }
}

export default App; 
import React from 'react';
import './App.css';

import List from './Components/List';
import TaskForm from './Components/TaskForm';

import TaskList from './Sample/TaskList.json'
class App extends React.Component{
  
  state = {
    taskLists: TaskList
  }
  
  addTask = (title,description) => {
    const newTask = {
      title: title,
      description: description,
      id: this.state.taskLists.length
    }
    this.setState({
      taskLists : [...this.state.taskLists, newTask]
    })
  }

  render(){
    return(
      <div>
        <TaskForm addTask={this.addTask} />
        <List tasks={this.state.taskLists} />
      </div>
    );
  }
}

export default App; 

Apareció cuando agregué esta parte de código:

this.setState({
      taskLists : [...this.state.taskLists, newTask]
    })

Hola estoy comenzando en react.js y estoy creando una "Lista de tareas" pero me sale este error: "Error: Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops" This is the code:

import './App.css';

import List from './Components/List';
import TaskForm from './Components/TaskForm';

import TaskList from './Sample/TaskList.json'
class App extends React.Component{
  
  state = {
    taskLists: TaskList
  }
  
  addTask = (title,description) => {
    const newTask = {
      title: title,
      description: description,
      id: this.state.taskLists.length
    }
    this.setState({
      taskLists : [...this.state.taskLists, newTask]
    })
  }

  render(){
    return(
      <div>
        <TaskForm addTask={this.addTask} />
        <List tasks={this.state.taskLists} />
      </div>
    );
  }
}

export default App; 

Apareció cuando agregué esta parte de código:

this.setState({
      taskLists : [...this.state.taskLists, newTask]
    })

Estoy creando una "Lista de tareas" pero me sale este error:

"Error: Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops"

Este es mi código:

import React from 'react';
import './App.css';

import List from './Components/List';
import TaskForm from './Components/TaskForm';

import TaskList from './Sample/TaskList.json'
class App extends React.Component{
  
  state = {
    taskLists: TaskList
  }
  
  addTask = (title,description) => {
    const newTask = {
      title: title,
      description: description,
      id: this.state.taskLists.length
    }
    this.setState({
      taskLists : [...this.state.taskLists, newTask]
    })
  }

  render(){
    return(
      <div>
        <TaskForm addTask={this.addTask} />
        <List tasks={this.state.taskLists} />
      </div>
    );
  }
}

export default App; 

Apareció cuando agregué esta parte de código:

this.setState({
      taskLists : [...this.state.taskLists, newTask]
    })
se añadieron 326 caracteres en el cuerpo; título editado
Origen Enlace
Diego
  • 5
  • 1
  • 4

Hi, I'm just learning react.js and I'm creating a "task list" and it appears: "Error: Maximum update depth exceeded"

import React from 'react'; import './App.css';

import List from './Components/List'; import TaskForm from './Components/TaskForm';

import TaskList from './Sample/TaskList.json' class App extends ReactHola estoy comenzando en react.Component{

state = { taskLists: TaskList }

addTask = (title,description) => { const newTask = { title: title, descriptionjs y estoy creando una "Lista de tareas" pero me sale este error: description, id"Error: this.state.taskListsMaximum update depth exceeded.length } this This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate.setState({ React limits the number of nested updates to prevent infinite loops" taskLists This is the code: [...this.state.taskLists, newTask] }) }

render(){ return( ); } }

import './App.css';

import List from './Components/List';
import TaskForm from './Components/TaskForm';

import TaskList from './Sample/TaskList.json'
class App extends React.Component{
  
  state = {
    taskLists: TaskList
  }
  
  addTask = (title,description) => {
    const newTask = {
      title: title,
      description: description,
      id: this.state.taskLists.length
    }
    this.setState({
      taskLists : [...this.state.taskLists, newTask]
    })
  }

  render(){
    return(
      <div>
        <TaskForm addTask={this.addTask} />
        <List tasks={this.state.taskLists} />
      </div>
    );
  }
}

export default App; 

export default App;Apareció cuando agregué esta parte de código:

this.setState({
      taskLists : [...this.state.taskLists, newTask]
    })

Hi, I'm just learning react.js and I'm creating a "task list" and it appears: "Error: Maximum update depth exceeded"

import React from 'react'; import './App.css';

import List from './Components/List'; import TaskForm from './Components/TaskForm';

import TaskList from './Sample/TaskList.json' class App extends React.Component{

state = { taskLists: TaskList }

addTask = (title,description) => { const newTask = { title: title, description: description, id: this.state.taskLists.length } this.setState({ taskLists : [...this.state.taskLists, newTask] }) }

render(){ return( ); } }

export default App;

"Error: Maximum update depth exceeded"

Hola estoy comenzando en react.js y estoy creando una "Lista de tareas" pero me sale este error: "Error: Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops" This is the code:

import './App.css';

import List from './Components/List';
import TaskForm from './Components/TaskForm';

import TaskList from './Sample/TaskList.json'
class App extends React.Component{
  
  state = {
    taskLists: TaskList
  }
  
  addTask = (title,description) => {
    const newTask = {
      title: title,
      description: description,
      id: this.state.taskLists.length
    }
    this.setState({
      taskLists : [...this.state.taskLists, newTask]
    })
  }

  render(){
    return(
      <div>
        <TaskForm addTask={this.addTask} />
        <List tasks={this.state.taskLists} />
      </div>
    );
  }
}

export default App; 

Apareció cuando agregué esta parte de código:

this.setState({
      taskLists : [...this.state.taskLists, newTask]
    })
Origen Enlace
Diego
  • 5
  • 1
  • 4

Hi, I'm just learning react.js and I'm creating a "task list" and it appears: "Error: Maximum update depth exceeded"

import React from 'react'; import './App.css';

import List from './Components/List'; import TaskForm from './Components/TaskForm';

import TaskList from './Sample/TaskList.json' class App extends React.Component{

state = { taskLists: TaskList }

addTask = (title,description) => { const newTask = { title: title, description: description, id: this.state.taskLists.length } this.setState({ taskLists : [...this.state.taskLists, newTask] }) }

render(){ return( ); } }

export default App;