Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thank you for useAppState, but could you also export previousAppState #313

Closed
marcmoo opened this issue Jul 11, 2022 · 2 comments
Closed

Comments

@marcmoo
Copy link

marcmoo commented Jul 11, 2022

some times we need to have previous state to make sure preious state was 'background' or 'inactive' and currentstate is active, so we will call a method. but currently the only state it returns is currentState.

@3KINGZ
Copy link

3KINGZ commented Sep 13, 2022

@marcmoo what was your workaround for this?

@pvinis
Copy link
Member

pvinis commented Feb 21, 2025

Not sure why you would need this, but in any case, the way to do this is:

import { useAppState } from "@react-native-community/hooks"
import usePrevious from "react-use/lib/usePrevious"

function App() {
  const appState = useAppState()
  const prevAppState = usePrevious(appState)

}

@pvinis pvinis closed this as completed Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants