State Management Advice
Hi everyone, I have a lot of nesting components inside a single component in which I need to share the state that means I have to pass nested props that look kinda ugly to me and then the state is also shared among two components on the same page. Currently I'm using Pinia store but that makes it a global state that stays throughout the lifecycle of the whole app. I'm seeking any advice that anybody can give on this.
Thanks for your time
2 Replies
You could set the state in the parent component and use
provide
& inject
to pass the state to all child components only and not global state.I recommend using pinia, any other method would become a hassle in the future, with pinia you can always create a new store and rewrite a new efficient code when the idea drops in