fix: Fix AppState.removeListener
warning by using new API (#419)
* refactor: suppress AppState.removeListener warning by deprecation AppState.AddEventListener returns a remove function subscription, which replaces the removeListener method * fix: Property 'remove' does not exist on type 'void' * chore: add missing trailing comma * chore: update react-native static types version
This commit is contained in:
parent
ffb4a188a2
commit
1a4fd7a233
@ -35,7 +35,7 @@
|
||||
"@react-native-community/eslint-config": "^3.0.0",
|
||||
"@react-native-community/eslint-plugin": "^1.1.0",
|
||||
"@types/react": "^17.0.19",
|
||||
"@types/react-native": "^0.64.13",
|
||||
"@types/react-native": "^0.65.0",
|
||||
"@types/react-native-vector-icons": "^6.4.6",
|
||||
"@types/react-native-video": "^5.0.5",
|
||||
"babel-plugin-module-resolver": "^4.1.0",
|
||||
|
@ -9,8 +9,10 @@ export const useIsForeground = (): boolean => {
|
||||
const onChange = (state: AppStateStatus): void => {
|
||||
setIsForeground(state === 'active');
|
||||
};
|
||||
AppState.addEventListener('change', onChange);
|
||||
return () => AppState.removeEventListener('change', onChange);
|
||||
const subscription = AppState.addEventListener('change', onChange);
|
||||
return () => {
|
||||
subscription.remove();
|
||||
};
|
||||
}, [setIsForeground]);
|
||||
|
||||
return isForeground;
|
||||
|
@ -1056,13 +1056,20 @@
|
||||
"@types/react" "*"
|
||||
"@types/react-native" "*"
|
||||
|
||||
"@types/react-native@*", "@types/react-native@^0.64.13":
|
||||
"@types/react-native@*":
|
||||
version "0.64.13"
|
||||
resolved "https://registry.yarnpkg.com/@types/react-native/-/react-native-0.64.13.tgz#9e57b85631380b75979a09f5a97e1884299e8d5a"
|
||||
integrity sha512-QSOBN6m3TKBPFAcDhuFItDQtw1Fo1/FKDTHGeyeTwBXd3bu0V9s+oHEhntHN7PUK5dAOYFWsnO0wynWwS/KRxQ==
|
||||
dependencies:
|
||||
"@types/react" "*"
|
||||
|
||||
"@types/react-native@^0.65.0":
|
||||
version "0.65.0"
|
||||
resolved "https://registry.yarnpkg.com/@types/react-native/-/react-native-0.65.0.tgz#bef9ca619f421abafae891ac0629e27cbfe63b42"
|
||||
integrity sha512-GgM6d47SQM9a6iOWKsdseFtTsKZGvmbr0FEaJMdCVy2SJmgtUq5JVpr3+aqHdrJQrg93e08VxPAWmz0qUtIPOg==
|
||||
dependencies:
|
||||
"@types/react" "*"
|
||||
|
||||
"@types/react@*", "@types/react@^17.0.19":
|
||||
version "17.0.20"
|
||||
resolved "https://registry.yarnpkg.com/@types/react/-/react-17.0.20.tgz#a4284b184d47975c71658cd69e759b6bd37c3b8c"
|
||||
|
Loading…
Reference in New Issue
Block a user