Do I need to return **all** refs from the setup store? #2711
-
| As mentioned in the docs we need to return all state properties, created with  It was not clear to me and my colleagues, whether this rules apply to any  Exampleconst usePrivateUserRightsStore = defineStore(`private`, () => {
  const isAdmin = ref(false);
  return {
    isAdmin,
  };
});
export default defineStore(`public`, () => {
  const { isAdmin } = storeToRefs(usePrivateUserRightsStore()); // do I need to return `isAdmin` from this store?
  const checkIsAdmin = () => isAdmin.value;
  return {
    checkIsAdmin,
  };
});For this discussion I have 3 question: 
 | 
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
| 
 Regarding your example, any  | 
Beta Was this translation helpful? Give feedback.
-
| But, from the document "https://pinia.vuejs.org/cookbook/composing-stores.html#Nested-Stores" it demonstrated otherwise : import { defineStore } from 'pinia'
import { useUserStore } from './user'
import { apiPurchase } from './api'
export const useCartStore = defineStore('cart', () => {
  const user = useUserStore()
  const list = ref([])
  const summary = computed(() => {
    return `Hi ${user.name}, you have ${list.value.length} items in your cart. It costs ${price.value}.`
  })
  function purchase() {
    return apiPurchase(user.id, list.value)
  }
  return { summary, purchase }
})the  | 
Beta Was this translation helpful? Give feedback.
refandreactivecalls inside the store must be returnedRegarding your example, any
storeToRefs()implies an already existing reactive state, so you don't return that, it would duplicate the state inpinia.state.value