Reactjs 无法从API中提取数据并在React中绘制数据

Reactjs 无法从API中提取数据并在React中绘制数据,reactjs,react-google-charts,Reactjs,React Google Charts,我有一个API 我正在尝试从该API中获取数据,并使用绘制数据。 代码: 从“React”导入React; 从'@material ui/core/styles'导入{makeStyles}; 从“@material ui/core/Grid”导入网格; 从“@material ui/core/Card”导入卡片; 从“@material ui/core/CardContent”导入CardContent; 从“@material ui/core/Typography”导入排版 //图表 从“

我有一个API

我正在尝试从该API中获取数据,并使用绘制数据。
代码:

从“React”导入React;
从'@material ui/core/styles'导入{makeStyles};
从“@material ui/core/Grid”导入网格;
从“@material ui/core/Card”导入卡片;
从“@material ui/core/CardContent”导入CardContent;
从“@material ui/core/Typography”导入排版
//图表
从“反应谷歌图表”导入图表;
const useStyles=makeStyles((主题)=>({
根目录:{
flexGrow:1,
}
}));
导出默认函数仪表板(){
initialState={
dataLoadingStatus:“正在加载”,
图表数据:[]
}; 
didMount={async函数(params){
const response=等待获取(
'http://api.openweathermap.org/data/2.5/forecast?q=bengaluru&appid={API_KEY}',
)
const json=await response.json()
const temp_min=Object.keys(json.main.temp_min)
const temp_max=Object.values(json.main.temp_max)
常量图表数据=[['temp\u min'、'temp\u max']]
对于(假设i=0;i
当我尝试运行此代码时,出现以下错误:

第21:5行:“初始状态”未定义无未定义
第25:5行:未定义“didMount”无未定义
第36:13行:未定义“组件”无未定义
第43:12行:未定义“组件”无未定义
第61:37行:未定义“数据”无未定义
第61:44行:“组件”未定义无未定义 我错过了什么


嗯,在声明变量时没有使用var、let或const

Line 21:5: 'initialState' is not defined no-undef
Line 25:5: 'didMount' is not defined no-undef
Line 36:13: 'component' is not defined no-undef
Line 43:12: 'component' is not defined no-undef
Line 61:37: 'data' is not defined no-undef
Line 61:44: 'component' is not defined no-undef
Line 21:5: 'initialState' is not defined no-undef
Line 25:5: 'didMount' is not defined no-undef
Line 36:13: 'component' is not defined no-undef
Line 43:12: 'component' is not defined no-undef
Line 61:37: 'data' is not defined no-undef
Line 61:44: 'component' is not defined no-undef