Replies: 2 comments 1 reply
-
|
I also don't fully understand when a re-render is triggered. I use And I validated with useSWRConfig() that the cache is used and filled before the But still for some reason it causes 1 more render than required. isValidating always stays false. I couldn't use fallbackData because that seems to have some odd behaviours with revalidation. Then It wouldn't correctly fetch data when the key was changed. |
Beta Was this translation helpful? Give feedback.
-
|
@oste Did you end up finding an answer to this? Its so puzzling to understand this Here's an issue that got marked as completed - but I still dont think it should have: #1952 ie. if we fetch the data on server side and pass it as a prop to the component, the same component will still render twice age.tsx fetch-age.tsx |
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The docs mention deep comparison should prevent unnecessary re-renders here https://swr.vercel.app/docs/advanced/performance#deep-comparison
However, I am getting re-renders using code very similar to the next.js example here https://swr.vercel.app/docs/with-nextjs
When I log out
datain the Article component the data does not change but it is output twice indicating that there was a re-render.What is causing this to happen? It seems data should only be output once since it did not change.
I even mocked my fetcher to return like this and the problem still happens
Edit:
here is an example forked from the Next.js SSR example here https://swr.vercel.app/examples/ssr:
https://codesandbox.io/s/elastic-resonance-kyxkp
The only update I made was to change
const { data, error } = useSWR(API);toconst { data, error } = useSWR(API, fetcher);This causes
Is data ready? trueto log twiceBeta Was this translation helpful? Give feedback.
All reactions