Skip to content

Commit be02ed6

Browse files
feat: Remove usage of deprecated function removeListener (#591)
BREAKING CHANGE: From now on, we require `react-native>=0.65` to work correctly (because `[email protected]` deprecates the `removeListener` API that we were using before this change).
1 parent 1cf0d6d commit be02ed6

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@
5050
"semantic-release": "^17.1.2"
5151
},
5252
"peerDependencies": {
53-
"@react-native-community/datetimepicker": ">=3.0.0"
53+
"@react-native-community/datetimepicker": ">=3.0.0",
54+
"react-native": ">=0.65.0"
5455
},
5556
"husky": {
5657
"hooks": {

src/Modal.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,22 +36,21 @@ export class Modal extends Component {
3636
animVal = new Animated.Value(0);
3737
_isMounted = false;
3838

39+
static _deviceEventEmitter = null;
40+
3941
componentDidMount() {
4042
this._isMounted = true;
4143
if (this.state.isVisible) {
4244
this.show();
4345
}
44-
DeviceEventEmitter.addListener(
46+
this._deviceEventEmitter = DeviceEventEmitter.addListener(
4547
"didUpdateDimensions",
4648
this.handleDimensionsUpdate
4749
);
4850
}
4951

5052
componentWillUnmount() {
51-
DeviceEventEmitter.removeListener(
52-
"didUpdateDimensions",
53-
this.handleDimensionsUpdate
54-
);
53+
this._deviceEventEmitter.remove();
5554
this._isMounted = false;
5655
}
5756

0 commit comments

Comments
 (0)