我遇到以下错误:
React Hook“ useEffect”在函数“ shoes”中被调用,该函数既不是React函数组件也不是自定义的React Hook函数react-hooks / rules-of-hooks
我不确定代码中到底是什么错误:
import React, {useState, useEffect} from 'react';
import "../App.css"
function shoes() {
useEffect(() => {
fetchItems();
}, []);
const fetchItems = async () => {
const data = await fetch('xxxxxxxxxxxxxxxxxxxxx')
console.log(data)
};
return ( < h1 className = "main" > Shoes < /h1> );
}
}
export default shoes;