mirror of
https://github.com/zoriya/react-native-web.git
synced 2026-06-01 10:07:35 +00:00
[fix] AppState.isSupported -> AppState.isAvailable
React Native exposes AppState support via 'isAvailable'.
This commit is contained in:
@@ -13,10 +13,10 @@ const AppStates = {
|
|||||||
const listeners = [];
|
const listeners = [];
|
||||||
|
|
||||||
class AppState {
|
class AppState {
|
||||||
static isSupported = ExecutionEnvironment.canUseDOM && document.visibilityState;
|
static isAvailable = ExecutionEnvironment.canUseDOM && document.visibilityState;
|
||||||
|
|
||||||
static get currentState() {
|
static get currentState() {
|
||||||
if (!AppState.isSupported) {
|
if (!AppState.isAvailable) {
|
||||||
return AppState.ACTIVE;
|
return AppState.ACTIVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,7 +31,7 @@ class AppState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static addEventListener(type: string, handler: Function) {
|
static addEventListener(type: string, handler: Function) {
|
||||||
if (AppState.isSupported) {
|
if (AppState.isAvailable) {
|
||||||
invariant(
|
invariant(
|
||||||
EVENT_TYPES.indexOf(type) !== -1,
|
EVENT_TYPES.indexOf(type) !== -1,
|
||||||
'Trying to subscribe to unknown event: "%s"',
|
'Trying to subscribe to unknown event: "%s"',
|
||||||
@@ -44,7 +44,7 @@ class AppState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static removeEventListener(type: string, handler: Function) {
|
static removeEventListener(type: string, handler: Function) {
|
||||||
if (AppState.isSupported) {
|
if (AppState.isAvailable) {
|
||||||
invariant(
|
invariant(
|
||||||
EVENT_TYPES.indexOf(type) !== -1,
|
EVENT_TYPES.indexOf(type) !== -1,
|
||||||
'Trying to remove listener for unknown event: "%s"',
|
'Trying to remove listener for unknown event: "%s"',
|
||||||
|
|||||||
Reference in New Issue
Block a user