I am dealing with react useContext and I and not able to update my golbal state value in each and every screen.
I am trying to change my theam color in App but it is reflect in that screen from where I change but when I navigate to another Screen I am not able to to see the change only default value is passing.
please help me with this.
I have tried to update my value and pass the value but I am not able to update it only shown in the same screen from where I have the feature of change theam color. but in another screen the change is not reflected.
2
Answers
The react office documentation provides a clear explanation of
useContext
and how to implement it for the use-case you asked. Check thisI suggest using a State Management library, like Redux Toolkit. It is easy to understand and also will help you store and update the state of the application.
I didn’t use useContext much but maybe you need to check if this is happening only in one use-case – the one you described – or there is a general problem inside the app