我有这个反应组件
import React, { useState, useEffect } from 'react';
import axios from "axios";
import "../../css/driversStandings.css";
function DriversStandingsComponent() {
const [data, setData] = useState([]);
var row = 1;
useEffect(() => {
axios.get("http://localhost:4000/api/standings").then(res => {
const driversChampionshipData = res.data[0].DriversChampionship
setData(driversChampionshipData);
console.log(data)
})
});
return (
//Here I return a mdbootstrap table, mapping the data array
)
}
export default DriversStandingsComponent;
Run Code Online (Sandbox Code Playgroud)
我真的不明白为什么会发生这种情况,以及它是否会影响服务器性能。
有解决这个问题的想法吗?我什至不知道这本身是否是一个错误