I'm currently building up a mobile app using React-Native with React-Redux. Is there a way to access a Redux state (getState()) from within a function that's not in a component?
Asked
Active
Viewed 494 times
1 Answers
0
Per the documentation, there are two ways you can use the AppState.
- Accessing
AppState.currentStateto get the current state (kept updated). - Adding an event listener to the changes to AppState through
AppState.addEventListener(type, handler).
If you need it once, use the first one. However, if you need to check for changes use the second.
H. Tugkan Kibar
- 2,215
- 13
- 17
-
Sorry, I was refering to a redux state, I updated the question and marked it as duplicate. Thanks. – Daniel Facciabene Jan 05 '18 at 18:29