Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

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.

import React, { Component } from 'react';
import styled from 'styled-components';

class Item extends React.Component {
    constructor(props) {
        super(props);     
        this.toggle= this.toggle.bind(this);
        this.state = {
            details: false
        } 
    }  
    toggle(){
        const currentState = this.state.details;
        this.setState({ details: !currentState }); 
    }

    render() {
        return (
            <tr className="Item"> 
                <td>{this.props.config.server}</td>      
                <td>{this.props.config.verbose}</td> 
                <td>{this.props.config.type}</td>
                <td className={this.state.details ? "visible" : "hidden"}>PLACEHOLDER MORE INFO</td>
                {<td><span onClick={this.toggle()}>Details</span></td>}
            </tr>
    )}
}

export default Item;
Comment

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.

when handle event,change this.toggle() to this.toggle or {()=> this.toggle()}
Comment

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.

{<td><span onClick={this.toggle()}>Details</span></td>}
Comment

PREVIOUS NEXT
Code Example
Typescript :: custom events in unity c# 
Typescript :: typescript module 
Typescript :: what is hello world in typescript 
Typescript :: HHow to append lists elixir 
Typescript :: ts factory pattern 
Typescript :: nuxt "AxiosRequestConfig" 
Typescript :: how to pring events in pygame 
Typescript :: how to add command line arguments in vscode 
Typescript :: react typescript append to array 
Typescript :: how to define array of object type in typescript 
Typescript :: convert javascript to typescript 
Typescript :: typescript cheatsheet 
Typescript :: ncbi datasets command-line tool 
Typescript :: react native mime type converter 
Typescript :: using method parameters in a guard nestjs 
Typescript :: how to use the pokeapi in javascript 
Typescript :: typescript public function 
Typescript :: modifying 2d lists python 
Typescript :: cpt ui plugin hidden single post type from search results in website 
Typescript :: can we do system testing at any stage 
Typescript :: studying for a sceince test 
Typescript :: access dict elements with dot 
Typescript :: numpy select elements from array condition 
Typescript :: how to use client and webresource objects to do https call 
Typescript :: typescript programmatically union 
Typescript :: powershell copy contents of keyvault to another keyvault 
Typescript :: Many plants obtain glucose through the process of ---- 
Typescript :: pptxgenjs bullet 
Typescript :: which of the following are elements associated with the html table layout? 
Typescript :: does key repeats in hashmap 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =