Closed dolie closed 2 years ago
I can see that SWR import 'react' under the hood... Is there any config to use preact/hooks instead ? Maybe it is the reason why it does not work.
I solved my problem.
1) SWR run as expected with Preact (FYI it adds nothing to the bundle, even with React as a dependency).
2) It seems that the browser treat the calls with different headers as the same calls. So it return the same cache for en-US
, fr-FR
, ja-JP
. (it does a Map only with url as keys)
3) In conclusion : I must add locale as a querystring so it forces the browser to do not see as the same API call, and make a new fetch (even if the API don't care about the querystring but only about the headers) and do not return cache.
Thank you for this great lib !
Bug report
Cache is not revalidated, but keys have changed.
Description / Observed Behavior
SWR in Preact app (using signals) cache is not revalidated when keys have changed. After clearing cache, it does not refetch when keys change, and use cache instead.
As you can see, cache keys are differents. But the values are the same. (API returns something different for each locals, also local
ja-JP
should return error. I tried keys with both object and string).Expected Behavior
SWR detect correctly that keys have changed and do not use cache.
Repro Steps / Code Example
Additional Context
"@preact/signals": "^1.1.1", "preact": "^10.11.0", "preact-router": "^4.1.0", "swr": "^1.3.0"