"next": "12.3.0",
更准确地说,这不会一直发生,假设在 85% 时它工作正常,但有时浏览器点击冻结,我无法点击任何东西,我所能做的就是关闭它。
浏览器控制台和终端都没有错误,应用程序运行正常。
我有一个调用 API 的按钮,在接收数据后我想
router.push()
到同一页面。正如我提到的那样,它并没有一直发生,所以我的代码应该不是问题。
<Button
onClick={async() => {
await axios
.patch('url', updateTrackDto)
.then((res) => {
router.push(`/tracks`); // this is the path of the same page
}).catch((error) => {
console.log(error);
});
}>update</Button>
getServerSideProps :
export async function getServerSideProps(context) {
const trackId = context.params.trackId;
const track = await axios.get(`http://127.0.0.1:5000/track/get/${trackId}`);
return {
props: {
track: track.data,
},
};
}
我检查过,没有无限渲染或无限循环或任何未按预期工作的东西,启用了 stricMode。
getServerSideProps()
被多次调用会不会有问题?因为当我一直点击按钮时,这发生在第 8-9 次点击/getServerSideProps 调用