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
Data is not updated when fallbackData and revalidateOnMount: false are provided.
It doesn't matter that the key changes, the actual request is never made to get the new data based on that key.
Expected Behavior
I would expect SWR to fetch new data on key change.
Repro Steps / Code Example
Here's how our code looks like:
(we would like to take advantage of SSG and not request the data on client-side upon mount - only if the key changes)
constgetEndpoint=(page,count,filters)=>{// returns new endpoint based on filters like: https://my-api.com?page=1&count=10&buyPrice=true}constPage=({ fallbackData })=>{const[filters,setFilters]=useState(defaultFilters)constonChange=()=>{
...
setFilters(newFilters)}// Filters change, new endpoint is generated, but fetcher is never calledconst{ data }=useSWRInfinite((pageIndex)=>getEndpoint(pageIndex+1,10,filters),fetcher,{ fallbackData,revalidateOnMount: false});return(...)}exportasyncfunctiongetServerSideProps(context){constfallbackData=awaitgetFallbackData(context.query);return{props: {
fallbackData
},};}
Additional Context
SWR version: 1.2.1
Next.js: 12.0.10
The text was updated successfully, but these errors were encountered:
Bug report
Description / Observed Behavior
Data is not updated when
fallbackData
andrevalidateOnMount: false
are provided.It doesn't matter that the key changes, the actual request is never made to get the new data based on that key.
Expected Behavior
I would expect SWR to fetch new data on key change.
Repro Steps / Code Example
Here's how our code looks like:
(we would like to take advantage of SSG and not request the data on client-side upon mount - only if the key changes)
Additional Context
SWR version: 1.2.1
Next.js: 12.0.10
The text was updated successfully, but these errors were encountered: