Do I need to return **all** refs from the setup store? #2711
Answered
by
posva
Ilanaya
asked this question in
Help and Questions
-
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.
Answered by
posva
Jul 11, 2024
Replies: 1 comment
-
Regarding your example, any |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Ilanaya
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ref
andreactive
calls 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