const backUrl = "https://626d63f2e58c6fabe2d4dc9a.mockapi.io/items"
function Main() {
const [items, setItems] = useState([])
useEffect(() => {
async function fetchItems() {
const response = await fetch(backUrl);
const data = await response.json();
console.log("EffectUsed")
setItems(data)
}
fetchItems()
}, []);
}
同时,在渲染和重新渲染期间,钩子会触发 2 次。我不知道该怎么办了