Since this week I’ve been playing with Vue3 and it’s composition API and I’m getting pretty enthusiastic about it!
Now, I’m figuring out how composition functions can be used the best. If you think about an example for complex form, I’d love to use a composition function to have a single source of truth with state en methods to manipulate the form data. Multiple components should only handle the display of the form, and use the function to sync data.
Now, this blog (https://vueschool.io/articles/vuejs-tutorials/state-management-with-composition-api/) explained that you can create a ‘shared state’ to define a ref in the file, outside the function scope. Within the function a computed prop using that ref should be returned. This way multiple component can use the shared state.
My question is: is this best practice? Is this the way you want to share state between multiple components?
I’d like to see your examples!