C. useStoreA is not called as a function, so storeA is not a store instance
D. State must be a function returning an object
Solution
Step 1: Check how useStoreA is used inside updateValue
useStoreA is referenced without parentheses, so storeA is a function reference, not a store instance.
Step 2: Understand consequences of missing parentheses
Without calling useStoreA(), you cannot access or modify state like storeA.value.
Final Answer:
useStoreA is not called as a function, so storeA is not a store instance -> Option C
Quick Check:
Call useStoreA() to get store instance [OK]
Hint: Always call useStore() with () to get the store [OK]
Common Mistakes:
Forgetting parentheses when calling useStore
Trying to assign state directly without actions
Misunderstanding defineStore usage
5. You have two stores: useCartStore managing cart items and useUserStore managing user info. You want to clear the cart when the user logs out. How should you implement this store-to-store interaction inside useUserStore?
hard
A. Inside the logout action, call const cart = useCartStore(); cart.clearItems();
B. Emit an event from useUserStore and listen in useCartStore to clear items
C. Directly modify useCartStore state without calling its actions
D. Reset useUserStore state and expect useCartStore to reset automatically
Solution
Step 1: Identify the correct way to trigger cart clearing
Calling useCartStore() inside useUserStore's logout action gets the cart store instance.
Step 2: Use cart store's action to clear items
Calling cart.clearItems() properly updates the cart state in a controlled way.
Final Answer:
Inside the logout action, call const cart = useCartStore(); cart.clearItems(); -> Option A
Quick Check:
Call other store's action inside logout to clear cart [OK]
Hint: Call other store's action inside your store's action [OK]
Common Mistakes:
Trying to modify other store's state directly
Using events instead of direct store calls
Expecting automatic reset without explicit calls
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.