In my current project, I've implemented two different types of Pinia storage definitions. Here's a condensed look at each:
// First Storage Definition using storeSetup
export const useStore = defineStore("storeId", () => {
const isExpanded: Ref<boolean> = ref(false);
return { isExpanded };
})
// Second Storage Definition using options
const useStore = defineStore("storeId2", {
state: () => ({
isExpanded: ref(false),
}),
getters: {
getIsExpanded: (state) => state.isExpanded,
},
});
If I were to use both stores with storeToRefs to extract isExpanded like this
const store = useStore();
const { isExpanded } = storeToRefs(store);
Would they function in the same way or behave differently?
I'm facing an issue where one of the examples isn't reactive, and it's causing problems with components not rendering as expected. Any insights on why this might be happening would be greatly appreciated.