initialData with placeholderData? #8251
-
Hello! I'm building a page where we have a table. The application is built in NextJs 14 and we initially fetch the data on the server and provide the data to the client component where we initiate the useQuery initialData with the data fetched on the server. But what happens now is that every time you press next page on the pagination stepper the table shows the initalData as a "placeholder" on every page. We have tried using only placeholderData, but same behavior. What are we doing wrong here?
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 12 replies
-
when the key changes ( you have to be specific with
|
Beta Was this translation helpful? Give feedback.
that is what’s happening. but the queryKeys
['organizations', { filters: 'foo' }]
and['organizations', { filters: 'bar' }]
are two different queries. So when you switch filters, you might create a new query if it does not exist, and then theinitialData
function runs.The options are:
initialData
when the filter equals the default filter<HydationBoundary>
instead ofinitialData
for SSR. This is very likely the better choice.