阿肥有遠端抓資料
const [dataList, setData] = useState([]);
useEffect(() => {
const fetchData1 = async () => {
const response = await
fetch('http://localhost/abc/def'){
method: "POST",
}
);
var data = await response.json();
setData(data);
};
然後路由
return (
<BrowserRouter>
<Routes>
<Route path={dataList.aaa} element={<Home />} />
</Routes>
</BrowserRouter>
)
理論上我連上前端網站 /aaa
應該要有資料
但是全紅畫面
Cannot read properties of undefined (reading 'data')
阿肥哪裡弄錯惹