**> I have a function to dynamically change the language of the page but
only the one of the "navbar" component is changed, for that I have created a global variable but the default value is not changed.**
CodePudding user response:
You should never use plain global variables in React app as their change will not trigger rerender of the component tree. If you need a variable accessible globally in your app use Context or some state management library like Jotai or in more complex cases Redux.
CodePudding user response: