redux-toolkit
redux-toolkit copied to clipboard
Am I missunderstanding RTK Query Cache feature?
When I make a request in Lazy Query, I cache the returned result and try to use the data in the cache even if the page changes. I make a request, the result is returned, and when I change the page, it appears as data: undefined, even though I set the preferCacheValu to true. What am I doing wrong? My code is given below;
const [
getCachedStockDocumentList,
{ data: stockDocumentListData}
] = mrpApi.endpoints.getApiStockDocumentStockDocumentList.useLazyQuery();
console.log(stockDocumentListData)
//request
onClick={async () => await getCachedStockDocumentList({}, true)}