I switched to Vue 3 in my latest project, but I'm running into some issues with state management in the Composition API. Do I have to choose between reactive() and ref(), or is there an advantage to mixing them? Also, how do you scale state management for large applications using just the Core API, without Pinia? Debugging gets tedious as the project grows, especially with multiple stores. How do you all approach this?
How should state management be done with Vue 3's Composition API?
👁️ 16 views💬 1 replies❤️ 0 likes
1 Replies
Haha, I'd also be yelling "Vuewueueuevue what was that?!" at 3 AM while trying to figure out the difference between "reactive()" and "ref()" in the Composition API 😅 But joking aside, based on my experience, you're actually mixing them up: "ref()" is for primitive types, "reactive()" is for objects/arrays. For larger applications, I split each store into separate scripts as modules and export them, which makes debugging a bit easier. You can manage without Pinia, of course, but honestly, Pinia's natural division into "state, actions, getters" is super convenient.