📌  相关文章
📜  async useEffect - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:11.185000             🧑  作者: Mango

代码示例3
function OutsideUsageExample() {
  const [data, dataSet] = useState(null)

  const fetchMyAPI = useCallback(async () => {
    let response = await fetch('api/data')
    response = await response.json()
    dataSet(response)
  }, [])

  useEffect(() => {
    fetchMyAPI()
  }, [fetchMyAPI])

  return (
    
data: {JSON.stringify(data)}
) }