Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

171
Visualizações
React shows wrong data. I guess it just dont update

React shows wrong data. I guess it just dont update. I cant solve this problem for 2 days. Help please. What is wrong here? I tried to fix componentdidmount but unfortunatelly it didn't help

class Table extends React.Component {

    constructor(props) {
        super(props);
        this.state  = {data: []}
    }

    componentDidMount() {
        this.data = setInterval(() =>
                console.log(this.setState({data})),
                this.setState(
            fetch('/lk/reports/3/month-ajax')
                .then(response => response.json())
                .then(data => this.setState({data})))
            , 50);
    }

    componentWillUnmount() {
        clearInterval(this.data);


    }


    render() {
        if (this.state.data.length == 0) {
            return (<div className="table-wrapper mt-5 d-flex justify-content-center">
                <i className="fas fa-spinner fa-3x fa-fw fa-spin"></i>
            </div>);
        } else {
            return (
        
               <table className="table highlight responsive-table">
                     <thead className="teal lighten-4">
                          <tr>
                                     
                                                <th>{this.state.data.time}</th>
                                            </tr>
                                            </thead>
                                            <tbody>
                                            {this.state.data.kpi.map(item => <tr className={this.activeRow(item)}>

                                                <td>{item.client}</td>
                                                <td>{item.all_incidents}</td>
                                            </tr>)}
                                            </tbody>
                                        </table>
            );
        }
    }
}

Here is full react.js code Thank you!

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda