-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
feat(nuxt): reset asyncData to default value when calling clear/clearNuxtData #27295
Conversation
Run & review this pull request in StackBlitz Codeflow. |
@@ -333,7 +339,7 @@ export function useAsyncData< | |||
return nuxtApp._asyncDataPromises[key]! | |||
} | |||
|
|||
asyncData.clear = () => clearNuxtDataByKey(nuxtApp, key) | |||
asyncData.reset = asyncData.clear = () => clearNuxtDataByKey(nuxtApp, key) |
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.
Should we also rename clearNuxtDataByKey
to resetNuxtDataByKey
?
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.
Maybe part of a bigger question - should we rename clearNuxtData
? In fact I am wondering if it would be better to keep clear
/clearNuxtData
as reset
is a change and in most cases the default value is the empty state of the composable.
🔗 Linked issue
resolves #26269
📚 Description
This changes the default behaviour to reset
data.value
to the default provided by the user rather than unsetting it entirely to null/undefined.It's based on top of the branch for #27294 as it overlaps slightly in scope and mechanism for ensuring this is backwards compatible with
compatibilityVersion: 3
.