Ralat .isSuccess React Query berlaku apabila saya menggunakan axios untuk membuat permintaan dapatkan
<p><br /></p>
<pre class="brush:php;toolbar:false;">const searchInvoiceList = async (
plantLoc: rentetan,
invoiceOption: rentetan
) => {
biarkan data: InvoiceData[] = [];
tunggu aksios
.get(`${linkURL}inv/getControlList/${plantLoc}/${invoiceOption}`)
.then((respons) => {
data = response.data.sqlData;
})
.catch((error) => console.error(error));
mengembalikan data;
};
const fetchInvois = useQuery({
Kunci pertanyaan: [
"Data invois",
plantLocationOptionChecked.value,
invoiceOptionChecked.value,
],
queryFn: () =>
searchInvoiceList(
plantLocationOptionChecked.value,
invoiceOptionChecked.value
),
didayakan: palsu,
cuba semula: 0,
});
jika (fetchInvoices.isSuccess) {
if (fetchInvoices.data.length === 0) {
toast.error("搜索结果为空");
}
setFetchedInvoiceData(fetchInvoices.data);
}
jika (fetchInvoices.isError) {
console.log(fetchInvoices.error);
}</pre>
<p>我有一个按钮,有一个onClick事件,调用fetchInvoices.refetch()时出现错误。第一个错诇是月多。React限制了渲染次数以防止无限循环。”如果我去掉<kod>setFetchedInvoiceData(fetchInvoices.data);</code>并且数组返回为0,它会触发我的react-hot-toast函数<code>索索"且索索"且索);< ;/kod>但然后我会收到警告“在渲染不同组件(<kod>Apl</kod>)时无法更染不同组件(<kod>Apl</kod> gt;)”。我做错了什么,如何修复这个问题?</p>