Skip to content

Commit

Permalink
[change] Update Animated to support React 18
Browse files Browse the repository at this point in the history
And remove deprecated AppState.removeListener API

Fix #2378
  • Loading branch information
necolas committed Mar 20, 2023
1 parent fc0d84f commit f313893
Show file tree
Hide file tree
Showing 42 changed files with 1,706 additions and 1,164 deletions.
21 changes: 2 additions & 19 deletions packages/react-native-web/src/exports/AppState/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/

import invariant from 'fbjs/lib/invariant';
import EventEmitter from '../../vendor/react-native/emitter/_EventEmitter';
import EventEmitter from '../../vendor/react-native/vendor/emitter/EventEmitter';
import canUseDOM from '../../modules/canUseDom';

// Android 4.4 browser
Expand Down Expand Up @@ -61,6 +61,7 @@ export default class AppState {
if (type === 'change') {
if (!changeEmitter) {
changeEmitter = new EventEmitter();

document.addEventListener(
VISIBILITY_CHANGE_EVENT,
() => {
Expand All @@ -75,22 +76,4 @@ export default class AppState {
}
}
}

static removeEventListener(type: string, handler: Function) {
if (AppState.isAvailable) {
console.error(
`AppState.removeListener('${type}', ...): Method has been ` +
'deprecated. Please instead use `remove()` on the subscription ' +
'returned by `AppState.addEventListener`.'
);
invariant(
EVENT_TYPES.indexOf(type) !== -1,
'Trying to remove listener for unknown event: "%s"',
type
);
if (type === 'change' && changeEmitter) {
changeEmitter.removeListener(handler);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import RCTDeviceEventEmitter from '../../vendor/react-native/NativeEventEmitter/RCTDeviceEventEmitter';
import RCTDeviceEventEmitter from '../../vendor/react-native/EventEmitter/RCTDeviceEventEmitter';
export default RCTDeviceEventEmitter;
2 changes: 1 addition & 1 deletion packages/react-native-web/src/exports/Dimensions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @flow
*/

import type { EventSubscription } from '../../vendor/react-native/emitter/EventEmitter';
import type { EventSubscription } from '../../vendor/react-native/vendor/emitter/EventEmitter';
import invariant from 'fbjs/lib/invariant';
import canUseDOM from '../../modules/canUseDom';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
* @flow
*/

import NativeEventEmitter from '../../vendor/react-native/NativeEventEmitter';
import NativeEventEmitter from '../../vendor/react-native/EventEmitter/NativeEventEmitter';
export default NativeEventEmitter;
Loading

0 comments on commit f313893

Please sign in to comment.