From 09c2a1f06398d385b1f90315d6d648b8bafb5fe1 Mon Sep 17 00:00:00 2001 From: Bartosz Kaszubowski Date: Tue, 17 Nov 2026 00:01:00 +0100 Subject: [PATCH 1/2] docs: add `useAppState` hook and example, update states --- docs/appstate.md | 27 +++++++++++++++++++++++---- website/src/css/customTheme.scss | 8 ++++++++ 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/docs/appstate.md b/docs/appstate.md index cc68ba5cc05..d9770e24c84 100644 --- a/docs/appstate.md +++ b/docs/appstate.md @@ -9,17 +9,19 @@ AppState is frequently used to determine the intent and proper behavior when han ### App States -- `active` - The app is running in the foreground +- `active` - The app is running in the foreground. - `background` - The app is running in the background. The user is either: - in another app - on the home screen - - [Android] on another `Activity`, including temporary system activities such + -
Android
on another `Activity`, including temporary system activities such as autofill credential pickers (even if launched by your app or the system) -- [iOS] `inactive` - This is a state that occurs when transitioning between foreground & background, and during periods of inactivity such as entering the multitasking view, opening the Notification Center or in the event of an incoming call. +- `inactive`
iOS
- This is a state that occurs when transitioning between foreground & background, and during periods of inactivity such as entering the multitasking view, opening the Notification Center or in the event of an incoming call. +- `extension` - The app is running in an extension context. +- `unknown` - The current app state is not yet available. For more information, see [Apple's documentation](https://developer.apple.com/documentation/uikit/app_and_scenes/managing_your_app_s_life_cycle) -## Basic Usage +## Usage To see the current state, you can check `AppState.currentState`, which will be kept up-to-date. @@ -77,6 +79,23 @@ export default AppStateExample; This example will only ever appear to say "Current state is: active" because the app is only visible to the user when in the `active` state. If you want to experiment with the code we recommend to use your own device instead of embedded preview. +### Hook + +The `useAppState` hook returns the current app state and subscribes to state changes. When the state changes, the component that calls this hook re-renders. + +```tsx title="useAppState Hook Example" +import {useAppState, Text} from 'react-native'; + +const AppStateHookExample = () => { + const appState = useAppState(); + return Current state is: {appState}; +}; + +export default AppStateHookExample; +``` + +The hook returns one of the [app state values](#app-states). It returns `unknown` until `AppState` reports a recognized state. + --- # Reference diff --git a/website/src/css/customTheme.scss b/website/src/css/customTheme.scss index 2719e210f62..095c19bae9b 100644 --- a/website/src/css/customTheme.scss +++ b/website/src/css/customTheme.scss @@ -2130,6 +2130,14 @@ td .label { } } +ul, +ol { + .label { + padding: 0 8px; + line-height: 20px; + } +} + /* Mark pages as "new" using href attribute: - to show badge in all versions use "PAGEID" From fcd41f824788389d3daaef0d2ea613026dffc29d Mon Sep 17 00:00:00 2001 From: Bartosz Kaszubowski Date: Tue, 17 Nov 2026 00:25:19 +0100 Subject: [PATCH 2/2] add missing isAvailable, mark correctly states, add Android docs link --- docs/appstate.md | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/docs/appstate.md b/docs/appstate.md index d9770e24c84..a0ec25ff9bd 100644 --- a/docs/appstate.md +++ b/docs/appstate.md @@ -15,11 +15,11 @@ AppState is frequently used to determine the intent and proper behavior when han - on the home screen -
Android
on another `Activity`, including temporary system activities such as autofill credential pickers (even if launched by your app or the system) -- `inactive`
iOS
- This is a state that occurs when transitioning between foreground & background, and during periods of inactivity such as entering the multitasking view, opening the Notification Center or in the event of an incoming call. -- `extension` - The app is running in an extension context. -- `unknown` - The current app state is not yet available. +-
iOS
`inactive` - This is a state that occurs when transitioning between foreground/background, and during periods of inactivity such as entering the multitasking view, opening the Notification Center or in the event of an incoming call. +-
iOS
`extension` - The app is running in an extension context. +-
iOS
`unknown` - The current app state is not yet available. -For more information, see [Apple's documentation](https://developer.apple.com/documentation/uikit/app_and_scenes/managing_your_app_s_life_cycle) +For more information, see [Apple documentation](https://developer.apple.com/documentation/uikit/managing-your-app-s-life-cycle) and [Android documentation](https://developer.android.com/guide/components/activities/activity-lifecycle). ## Usage @@ -139,3 +139,9 @@ Sets up a function that will be called whenever the specified event type on AppS ```tsx static currentState: AppStateStatus; ``` + +### `isAvailable` + +```tsx +static isAvailable: boolean; +```