You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
const{ data, run }=useRequest(getInfo,{cacheKey:undefined})useEffect(()=>{run({RequestAmount: 5000,// success});setTimeout(()=>{run({RequestAmount: 50000,// error});},2000);},[]);console.log(data)// first time: {data: {RequestAmount:5000}}// second time: {data: {RequestAmount:5000}} same with first time
The text was updated successfully, but these errors were encountered:
看文档是说If options.cacheKey is set, useRequest will cache the successful data . The next time the component is initialized, if there is cached data, we will return the cached data first, and then send a new request in background, which is the ability of SWR.会缓存成功时候的数据https://ahooks.js.org/hooks/use-request/cache#cache--swr
当第一次执行成功时,data的值是正确的,但是如果,第二次请求参数不同导致的error,不会让data变为undefined, 而是上次成功的值,我不知道这是一个bug还是feat
The text was updated successfully, but these errors were encountered: