欢迎浏览我公司网站!!
公司动态
Placeholder Query Data_1
时间: 2025-07-26浏览次数:
Placeholderdataallowsaquerytobehaveasifitalreadyhasdata,similartotheinitialDataoption,butthedataisnotpersistedtothecache.Thiscomesinhandyforsituationswhereyouhaveenoughpartial(orfake)datatorenderthequ

Placeholder data allows a query to behave as if it already has data, similar to the initialData option, but the data is not persisted to the cache. This comes in handy for situations where you have enough partial (or fake) data to render the query successfully while the actual data is fetched in the background.

Example: An individual blog post query could pull "preview" data from a parent list of blog posts that only include title and a small snippet of the post body. You would not want to persist this partial data to the query result of the individual query, but it is useful for showing the content layout as quickly as possible while the actual query finishes to fetch the entire object.

There are a few ways to supply placeholder data for a query to the cache before you need it:

tsx

If the process for accessing a query's placeholder data is intensive or just not something you want to perform on every render, you can memoize the value:

tsx

In some circumstances, you may be able to provide the placeholder data for a query from the cached result of another. A good example of this would be searching the cached data from a blog post list query for a preview version of the post, then using that as the placeholder data for your individual post query:

tsx

For a comparison between Placeholder Data and Initial Data, have a look at the Community Resources.


Copyright © 2002-2022 盛煌-盛煌娱乐-盛煌全球注册认证站 版权所有

粤IP*******

平台注册入口