DEV Community

Discussion on: You Might Not Need Vuex with Vue 3

sylvainpolletvillard profile image
Sylvain Pollet-Villard

What is the benefit of provide/inject compared to directly import { state } ?

vuesomedev profile image
Gábor Soós Author

The second import solution creates a tightly coupled store, which makes testing, using another store with the same interface, using different stores in different parts of the application hard.

Both solutions work. The second one is simpler but hardly coupled to the implementation. The first one is a bit more complex but makes the code more open to alteration.

ozzythegiant profile image
Oziel Perez

This is why one must try their best to ensure that with a tightly coupled store, such stores are only used at top level components, leaving the rest to be dumb components used only to display data or emit an event