React muestra datos incorrectos. Supongo que simplemente no se actualiza. No puedo resolver este problema durante 2 días. Ayuda por favor. ¿Que esta mal aquí? Traté de arreglar el componente no se montó, pero desafortunadamente no funcionó.
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> ); } } }Aquí está el código completo de react.js ¡Gracias!