Open shfshanyue opened 4 years ago
import React, { Fragment, useState, useEffect } from "react";
function App() { const [data, setData] = useState([]); useEffect(() => { async function fetchData() { // You can await here const response = await MyAPI.getData(someId); setData(response); } fetchData(); }, []); return (
); }
export default App;
比如设计成
useFetch
这种形式,它的 API 应该如何设计