如何在新的reactjs钩子api中调用restApi.并使用useEffects和useState重用数据?我想只重用组件之间的数据.
import { useState, useEffect } from "react";
export default function getAdvice(url) {
fetch(`http://api.adviceslip.com/advice`)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.log(err)
}
Run Code Online (Sandbox Code Playgroud)