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

167
Views
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
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!