我尝试使用useEffect,但出现如下所示的错误,
React Hook useEffect has a missing dependency: 'data'. Either include it or remove the dependency array
这是我的组成部分
let id = props.location.pathname.split("--")[1];
let str = props.location.pathname.split("--")[0].substr(1);
const data = {id: id,link: str}
const [title,setTitle] = useState("")
useEffect(() => {
setTitle("...") // Yükleniyor.
async function getTitle() {
axios.post('/api/data/entry/get',data)
.then(res => {
setTitle(res.data.title)
// TODO: Catch ekle.
})
}
getTitle()
},[props])