I am new to React, so I dont know the best ways of implementing some sort of global state. I am currently working in React Native to develop a UI. I have different functional components for the different "things" on the screen. The next step in the development is to implement a shared state between the relevant functional components. The state in question is a simple integer value, which will determine parts of the design. I see there is many ways of implementing this state, but I dont know what is best. How should I implement my shared integer variable?
CodePudding user response:
There are various client state management library available. You can use any one of the. For example - Redux, Mobx
Redux I would like to suggest
CodePudding user response:
I'd suggest to look either at Redux or just React Context. I think either would work in your scenario, and both will be valuable to know if you keep working with React. :)
Now this is, of course, subjective, but I'd say Context might be easier to digest and get into when you're just starting out. And given that you only need to store some design-related data, it might be more than enough for starters. Redux has more complexity, but it definitely shines the more complex the state that you have to manage gets.
Context: https://reactjs.org/docs/context.html
Redux: https://react-redux.js.org/
