How to use urql as state management in React

767 Views Asked by At

I have a React app. I am use to using a state management system like Redux or using the useContext provided from React hooks. I now am working with GraphQL and I hooked my app to up to use urql. I want to be able to have a central state like in react in my project and to my understanding I should be able to achieve this with urql. What will be the setup for this exactly. For instance, say I have something simple like toggling dark mode on my website. I want that state to live in some central state which I can connect with all my other components using urql is this possible and if so how can I achieve this?

1

There are 1 best solutions below

1
On

You can combine both to manage global state, use redux or context api for local state management, toggle theme or any other local state that do not require network request, urql for data caching, where you can perform local data CRUD operation when hitting server.