Skip to content

Commit ab8dd55

Browse files
ursrudraTkDodo
andauthored
docs(examples): Update useAppState in react-native example (#5557)
* Update useAppState.ts Updating the cleanup function as the removeEventLister method is not available on AppState * Update useAppState.ts Removed Semicolons --------- Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
1 parent accecdd commit ab8dd55

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

examples/react/react-native/src/hooks/useAppState.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import { AppState, AppStateStatus } from 'react-native'
33

44
export function useAppState(onChange: (status: AppStateStatus) => void) {
55
useEffect(() => {
6-
AppState.addEventListener('change', onChange)
6+
const subscription = AppState.addEventListener('change', onChange)
77
return () => {
8-
AppState.removeEventListener('change', onChange)
8+
subscription.remove()
99
}
1010
}, [onChange])
1111
}

0 commit comments

Comments
 (0)