If I am not mistaken, useState
can replace any store like Pinia
? Given that useState
makes ref sharable across all components I have a hard time knowing if I should use a store or a useState ref. For instance, let's say I have a currentUser (firstName, lastName, email)
that I fetch from a distant API at page loading. Should I stock this information in a Pinia
userStore or in a useState('currentUser')
?
What are best practices on this topic?
useState() docs: https://v3.nuxtjs.org/api/composables/use-state
Pinia docs: https://pinia.vuejs.org/core-concepts/
This question is pretty much fully explained in the Why should I use Pinia section , I quote:
Here is a video of Evan You explaining it if you prefer.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.