DEV Community

Discussion on: How to manage global state with XState and React

 
mattpocockuk profile image
Matt Pocock

Why do you want the apollo mutation to be held in the global service? It feels more natural to me to have it in the component where it's used.

Thread Thread
 
equimper profile image
Emanuel Quimper

I want my service who is global for all the onboarding part to handle the logic and make component quite simple.

Thread Thread
 
mattpocockuk profile image
Matt Pocock

Right - I think that's a mistake. Instead, you should keep truly local state local. I would make a state machine inside the component to handle this.

Thread Thread
 
equimper profile image
Emanuel Quimper

Cause I was trying to implement like you show in the xstate catalog with the multi steps form. Was working well until this issue. Thank you