-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Docs for cacheSignal
#8023
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docs for cacheSignal
#8023
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,121 @@ | ||||||
--- | ||||||
title: cacheSignal | ||||||
--- | ||||||
|
||||||
<Canary> | ||||||
|
||||||
**The `cacheSignal()` API is currently only available in React’s Canary and Experimental channels.** | ||||||
|
||||||
[Learn more about React’s release channels here.](/community/versioning-policy#all-release-channels) | ||||||
|
||||||
</Canary> | ||||||
|
||||||
<RSC> | ||||||
|
||||||
`cacheSignal` is only for use with [React Server Components](/blog/2023/03/22/react-labs-what-we-have-been-working-on-march-2023#react-server-components). | ||||||
|
||||||
</RSC> | ||||||
|
||||||
<Intro> | ||||||
|
||||||
`cacheSignal()` returns an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) which aborts when the cache lifetime is done based on the same execution scope as a [`cache()`](/reference/react/cache)ed function | ||||||
|
`cacheSignal()` returns an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) which aborts when the cache lifetime is done based on the same execution scope as a [`cache()`](/reference/react/cache)ed function | |
`cacheSignal` allows you to know when the `cache()` life time is over. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This example doesn't make sense because you have no idea that the fetch here is using cache()
.
Can you use something like a DB example, like here?
https://react-do5kq6ru7-fbopensource.vercel.app/reference/react/cache#preload-data
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need to know if the call is cached or not. Just that it may be cached by cache()
.
Uh oh!
There was an error while loading. Please reload this page.