0

I am new to React Native, I am trying to change the state of an arithmetic function in a class component located in one screen and then share it globally in order to use it in different screens and possibly change it, what are some of the ways in which I can do this?

1 Answers1

0

You can either lift the state up or use context API

also maybe you should consider using React Hooks

maybe this thread is similar to your issue

also, these articles could help with the context 1, 2

Mohammed
  • 133
  • 9
  • I am using React Navigation to navigate through my bottom tab navigator, is it possible to use context API with it? –  Mar 17 '21 at 17:23
  • the context API has nothing to do with react-navigation it is a React API so it should work with react and react-native. you can check these: 1- [How to Use the React Context API to Build React Native, Expo, and Firebase Apps](https://levelup.gitconnected.com/how-to-use-the-react-context-api-to-build-react-native-expo-and-firebase-apps-adda840e52b0) 2- https://stackoverflow.com/questions/51187582/how-should-the-new-context-api-work-with-react-native-navigator – Mohammed Mar 17 '21 at 20:41